# ImmutableByteArray

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/ImmutableByteArray.java+class:androidx.media3.test.utils.ImmutableByteArray)

*** ** * ** ***

<br />

```
@UnstableApi
class ImmutableByteArray
```

<br />

*** ** * ** ***

`byte` version of `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/ImmutableIntArray.html`.

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

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray.Builder` Builder for `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray` instances. |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#concat(androidx.media3.test.utils.ImmutableByteArray...)(arrays: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray!>!)` Returns an instance containing the concatenated contents of `arrays`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#concatToArray(androidx.media3.test.utils.ImmutableByteArray...)(arrays: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray!>!)` Returns a `byte[]` containing the concatenated contents of `arrays`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#copyOf(java.util.Collection<java.lang.Byte>)(collection: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html!>!)` Returns an instance backed by a copy of `collection`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#copyOf(byte[])(values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Returns an instance backed by a copy of `values`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#equals(java.lang.Object)(obj: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#get(int)(i: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the `byte` at index `i`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#isEmpty()()` Returns true if this array contains no elements. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#length()()` Returns the number of elements in this array. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#of()()` Returns an empty instance. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#ofHexString(java.lang.String)(hexString: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns an instance containing the bytes encoded in `hexString`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#ofUnsigned(long,long...)(value1: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, otherValues: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!)` Returns an instance containing the provided `long` values converted to `byte` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#subArray(int,int)(startIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, endIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a new `byte[]` containing the elements from this instance between indexes ` startIndex` (inclusive) and `endIndex` (exclusive). |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#toArray()()` Returns a new `byte[]` containing the same elements as this instance. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImmutableByteArray#toString()()` |

## Public functions

### concat

```
java-static fun concat(arrays: Array<ImmutableByteArray!>!): ImmutableByteArray!
```

Returns an instance containing the concatenated contents of `arrays`.

### concatToArray

```
java-static fun concatToArray(arrays: Array<ImmutableByteArray!>!): Array<Byte>!
```

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

### copyOf

```
java-static fun copyOf(collection: (Mutable)Collection<Byte!>!): ImmutableByteArray!
```

Returns an instance backed by a copy of `collection`.

### copyOf

```
java-static fun copyOf(values: ByteArray<Byte>!): ImmutableByteArray!
```

Returns an instance backed by a copy of `values`.

### equals

```
fun equals(obj: Any?): Boolean
```

### get

```
fun get(i: Int): Byte
```

Returns the `byte` at index `i`.

### hashCode

```
fun hashCode(): Int
```

### isEmpty

```
fun isEmpty(): Boolean
```

Returns true if this array contains no elements.

### length

```
fun length(): Int
```

Returns the number of elements in this array.

### of

```
java-static fun of(): ImmutableByteArray!
```

Returns an empty instance.

### ofHexString

```
java-static fun ofHexString(hexString: String!): ImmutableByteArray!
```

Returns an instance containing the bytes encoded in `hexString`.

### ofUnsigned

```
java-static fun ofUnsigned(value1: Long, otherValues: LongArray<Long>!): ImmutableByteArray!
```

Returns an instance containing the provided `long` values converted to `byte` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)`.

### subArray

```
fun subArray(startIndex: Int, endIndex: Int): ImmutableByteArray!
```

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

### toArray

```
fun toArray(): Array<Byte>!
```

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

### toString

```
fun toString(): String!
```