/** * Returns a {@code TraceOptions} whose representation is {@code src}. * * @param src the byte representation of the {@code TraceOptions}. * @return a {@code TraceOptions} whose representation is {@code src}. * @since 0.16 */ public static TraceOptions fromByte(byte src) { // TODO(bdrutu): OPTIMIZATION: Cache all the 256 possible objects and return from the cache. return new TraceOptions(src); }
/** * Builds and returns a {@code TraceOptions} with the desired options. * * @return a {@code TraceOptions} with the desired options. */ public TraceOptions build() { return new TraceOptions(options); } }
/** * Returns a {@code TraceOption} built from a lowercase base16 representation. * * @param src the lowercase base16 representation. * @param srcOffset the offset in the buffer where the representation of the {@code TraceOptions} * begins. * @return a {@code TraceOption} built from a lowercase base16 representation. * @throws NullPointerException if {@code src} is null. * @throws IllegalArgumentException if {@code src.length} is not {@code 2 * TraceOption.SIZE} OR * if the {@code str} has invalid characters. * @since 0.18 */ public static TraceOptions fromLowerBase16(CharSequence src, int srcOffset) { return new TraceOptions(BigendianEncoding.byteFromBase16String(src, srcOffset)); }
/** * Returns a {@code TraceOptions} whose representation is copied from the {@code src} beginning at * the {@code srcOffset} offset. * * @param src the buffer where the representation of the {@code TraceOptions} is copied. * @param srcOffset the offset in the buffer where the representation of the {@code TraceOptions} * begins. * @return a {@code TraceOptions} whose representation is copied from the buffer. * @throws NullPointerException if {@code src} is null. * @throws IndexOutOfBoundsException if {@code srcOffset+TraceOptions.SIZE} is greater than {@code * src.length}. */ public static TraceOptions fromBytes(byte[] src, int srcOffset) { checkElementIndex(srcOffset, src.length); return new TraceOptions(src[srcOffset]); }
/** * Returns a {@code TraceOptions} built from a byte representation. * * <p>Equivalent with: * * <pre>{@code * TraceOptions.fromBytes(buffer, 0); * }</pre> * * @param buffer the representation of the {@code TraceOptions}. * @return a {@code TraceOptions} whose representation is given by the {@code buffer} parameter. * @throws NullPointerException if {@code buffer} is null. * @throws IllegalArgumentException if {@code buffer.length} is not {@link TraceOptions#SIZE}. */ public static TraceOptions fromBytes(byte[] buffer) { checkNotNull(buffer, "buffer"); checkArgument(buffer.length == SIZE, "Invalid size: expected %s, got %s", SIZE, buffer.length); return new TraceOptions(buffer[0]); }