Remove @Nullable from Dumper.add methods

`checkNotNull` was added to the `Object` variant in b83f12c4ba. It
doesn't seem to have caused any test failures, so I guess we never
pass `null` in here - and might as well update the annotation to match
reality. And then for consistency we should ban `null` from the
`byte[]` overload too.

PiperOrigin-RevId: 628419003
This commit is contained in:
ibaker 2024-04-26 08:54:26 -07:00 committed by Copybara-Service
parent 38813dd30e
commit e759b44c45
3 changed files with 8 additions and 11 deletions

View File

@ -15,6 +15,8 @@
*/
package androidx.media3.test.utils;
import static androidx.media3.common.util.Assertions.checkNotNull;
import androidx.annotation.Nullable;
import androidx.media3.common.ColorInfo;
import androidx.media3.common.Format;
@ -154,6 +156,7 @@ public final class DumpableFormat implements Dumper.Dumpable {
@Nullable Object fieldValue = getFieldFunction.apply(value);
@Nullable Object defaultFieldValue = getFieldFunction.apply(defaultValue);
if (!Util.areEqual(fieldValue, defaultFieldValue)) {
checkNotNull(fieldValue);
dumper.add(field, fieldValue);
}
}

View File

@ -15,9 +15,6 @@
*/
package androidx.media3.test.utils;
import static androidx.media3.common.util.Assertions.checkNotNull;
import androidx.annotation.Nullable;
import androidx.media3.common.C;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
@ -49,8 +46,7 @@ public final class Dumper {
}
@CanIgnoreReturnValue
public Dumper add(String field, @Nullable Object value) {
checkNotNull(value);
public Dumper add(String field, Object value) {
if (value instanceof byte[]) {
return add(field, (byte[]) value);
}
@ -72,14 +68,10 @@ public final class Dumper {
}
@CanIgnoreReturnValue
public Dumper add(String field, @Nullable byte[] value) {
public Dumper add(String field, byte[] value) {
String string =
String.format(
Locale.US,
"%s = length %d, hash %X",
field,
value == null ? 0 : value.length,
Arrays.hashCode(value));
Locale.US, "%s = length %d, hash %X", field, value.length, Arrays.hashCode(value));
return addLine(string);
}

View File

@ -15,6 +15,7 @@
*/
package androidx.media3.test.utils.robolectric;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static java.lang.Math.max;
import android.graphics.Bitmap;
@ -426,6 +427,7 @@ public final class PlaybackOutput implements Dumper.Dumpable {
private static void dumpIfNotEqual(
Dumper dumper, String field, @Nullable Object actual, @Nullable Object comparison) {
if (!Util.areEqual(actual, comparison)) {
checkNotNull(actual);
dumper.add(field, actual);
}
}