# ImmutableByteArray.Builder

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.Builder)

*** ** * ** ***


```
public final class ImmutableByteArray.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#Builder()()` Constructs a new instance with a default initial capacity. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#Builder(int)(int initialCapacity)` Constructs a new instance with the provided initial capacity. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#add(byte)(byte b)` Add the provided `byte` to the builder. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#addAll(byte[])(byte[] bytes)` Add the contents of the provided array to this builder. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#addAll(java.util.Collection<java.lang.Byte>)(https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/java/lang/Byte.html> bytes)` Add the contents of the provided collection to this builder. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#addAll(androidx.media3.test.utils.ImmutableByteArray)(https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray bytes)` Add the contents of the provided array to this builder. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#addAllUnsigned(long[])(long[] bytes)` Cast the elements of the provided `long[]` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)` and add them to the builder. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#addAllUnsigned(int[])(int[] bytes)` Cast the elements of the provided `int[]` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)` and add them to the builder. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#addAllUnsigned(java.util.Collection<java.lang.Long>)(https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/java/lang/Long.html> bytes)` Cast the elements of the provided `https://developer.android.com/reference/java/util/Collection.html` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)` and add them to the builder. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#addUnsigned(long)(long b)` Cast the provided `long` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)` and add it to the builder. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray` | `https://developer.android.com/reference/androidx/media3/test/utils/ImmutableByteArray.Builder#build()()` Returns the built array. |

## Public constructors

### Builder

```
public Builder()
```

Constructs a new instance with a default initial capacity.

### Builder

```
public Builder(int initialCapacity)
```

Constructs a new instance with the provided initial capacity.

## Public methods

### add

```
@CanIgnoreReturnValue
public ImmutableByteArray.Builder add(byte b)
```

Add the provided `byte` to the builder.

### addAll

```
@CanIgnoreReturnValue
public ImmutableByteArray.Builder addAll(byte[] bytes)
```

Add the contents of the provided array to this builder.

### addAll

```
@CanIgnoreReturnValue
public ImmutableByteArray.Builder addAll(Collection<Byte> bytes)
```

Add the contents of the provided collection to this builder.

### addAll

```
@CanIgnoreReturnValue
public ImmutableByteArray.Builder addAll(ImmutableByteArray bytes)
```

Add the contents of the provided array to this builder.

### addAllUnsigned

```
@CanIgnoreReturnValue
public ImmutableByteArray.Builder addAllUnsigned(long[] bytes)
```

Cast the elements of the provided `long[]` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)` and add them to the builder.

### addAllUnsigned

```
@CanIgnoreReturnValue
public ImmutableByteArray.Builder addAllUnsigned(int[] bytes)
```

Cast the elements of the provided `int[]` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)` and add them to the builder.

### addAllUnsigned

```
@CanIgnoreReturnValue
public ImmutableByteArray.Builder addAllUnsigned(Collection<Long> bytes)
```

Cast the elements of the provided `https://developer.android.com/reference/java/util/Collection.html` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)` and add them to the builder.

### addUnsigned

```
@CanIgnoreReturnValue
public ImmutableByteArray.Builder addUnsigned(long b)
```

Cast the provided `long` with `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/UnsignedBytes.html#checkedCast(long)` and add it to the builder.

### build

```
public ImmutableByteArray build()
```

Returns the built array.