ImmutableByteArray


@UnstableApi
public final class ImmutableByteArray


byte version of com.google.common.primitives.ImmutableIntArray.

This avoids the boxing/un-boxing costs of ImmutableList<Byte> and offers more ergonomic integration with APIs that expect a byte[].

Summary

Nested types

public final class ImmutableByteArray.Builder

Builder for ImmutableByteArray instances.

Public methods

static ImmutableByteArray
concat(ImmutableByteArray[] arrays)

Returns an instance containing the concatenated contents of arrays.

static byte[]
concatToArray(ImmutableByteArray[] arrays)

Returns a byte[] containing the concatenated contents of arrays.

static ImmutableByteArray
copyOf(Collection<Byte> collection)

Returns an instance backed by a copy of collection.

static ImmutableByteArray
copyOf(byte[] values)

Returns an instance backed by a copy of values.

byte
get(int i)

Returns the byte at index i.

boolean

Returns true if this array contains no elements.

int

Returns the number of elements in this array.

static ImmutableByteArray
of()

Returns an empty instance.

static ImmutableByteArray
ofHexString(String hexString)

Returns an instance containing the bytes encoded in hexString.

static ImmutableByteArray
ofUnsigned(long value1, long[] otherValues)

Returns an instance containing the provided long values converted to byte with checkedCast.

ImmutableByteArray
subArray(int startIndex, int endIndex)

Returns a new byte[] containing the elements from this instance between indexes startIndex (inclusive) and endIndex (exclusive).

byte[]

Returns a new byte[] containing the same elements as this instance.

Public methods

concat

public static ImmutableByteArray concat(ImmutableByteArray[] arrays)

Returns an instance containing the concatenated contents of arrays.

concatToArray

public static byte[] concatToArray(ImmutableByteArray[] arrays)

Returns a byte[] containing the concatenated contents of arrays.

copyOf

public static ImmutableByteArray copyOf(Collection<Byte> collection)

Returns an instance backed by a copy of collection.

copyOf

public static ImmutableByteArray copyOf(byte[] values)

Returns an instance backed by a copy of values.

get

public byte get(int i)

Returns the byte at index i.

isEmpty

public boolean isEmpty()

Returns true if this array contains no elements.

length

public int length()

Returns the number of elements in this array.

of

public static ImmutableByteArray of()

Returns an empty instance.

ofHexString

public static ImmutableByteArray ofHexString(String hexString)

Returns an instance containing the bytes encoded in hexString.

ofUnsigned

public static ImmutableByteArray ofUnsigned(long value1, long[] otherValues)

Returns an instance containing the provided long values converted to byte with checkedCast.

subArray

public ImmutableByteArray subArray(int startIndex, int endIndex)

Returns a new byte[] containing the elements from this instance between indexes startIndex (inclusive) and endIndex (exclusive).

toArray

public byte[] toArray()

Returns a new byte[] containing the same elements as this instance.