Keep method signature together when overriding

Not important, but when overriding a method that can return null,
it seems preferable to put @Override first, followed by what it's
overriding (which includes the @Nullable).

Also remove explicit @NonNull use in the core library. @NonNull is
propagated by default, so this is redundant.

PiperOrigin-RevId: 296188379
This commit is contained in:
olly 2020-02-20 13:43:52 +00:00 committed by Oliver Woodman
parent 95ba4f85b0
commit 47133f46cb
25 changed files with 35 additions and 49 deletions

View File

@ -88,8 +88,8 @@ import java.nio.ByteBuffer;
return new VideoDecoderOutputBuffer(this::releaseOutputBuffer); return new VideoDecoderOutputBuffer(this::releaseOutputBuffer);
} }
@Nullable
@Override @Override
@Nullable
protected Gav1DecoderException decode( protected Gav1DecoderException decode(
VideoDecoderInputBuffer inputBuffer, VideoDecoderOutputBuffer outputBuffer, boolean reset) { VideoDecoderInputBuffer inputBuffer, VideoDecoderOutputBuffer outputBuffer, boolean reset) {
ByteBuffer inputData = Util.castNonNull(inputBuffer.data); ByteBuffer inputData = Util.castNonNull(inputBuffer.data);

View File

@ -64,8 +64,8 @@ public final class DummyExoMediaDrm<T extends ExoMediaCrypto> implements ExoMedi
throw new IllegalStateException(); throw new IllegalStateException();
} }
@Nullable
@Override @Override
@Nullable
public byte[] provideKeyResponse(byte[] scope, byte[] response) { public byte[] provideKeyResponse(byte[] scope, byte[] response) {
// Should not be invoked. No session should exist. // Should not be invoked. No session should exist.
throw new IllegalStateException(); throw new IllegalStateException();

View File

@ -179,8 +179,8 @@ public final class FrameworkMediaDrm implements ExoMediaDrm<FrameworkMediaCrypto
return new KeyRequest(requestData, licenseServerUrl); return new KeyRequest(requestData, licenseServerUrl);
} }
@Nullable
@Override @Override
@Nullable
public byte[] provideKeyResponse(byte[] scope, byte[] response) public byte[] provideKeyResponse(byte[] scope, byte[] response)
throws NotProvisionedException, DeniedByServerException { throws NotProvisionedException, DeniedByServerException {
if (C.CLEARKEY_UUID.equals(uuid)) { if (C.CLEARKEY_UUID.equals(uuid)) {

View File

@ -21,7 +21,6 @@ import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.os.Message; import android.os.Message;
import androidx.annotation.GuardedBy; import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
@ -86,7 +85,7 @@ class AsynchronousMediaCodecBufferEnqueuer implements MediaCodecInputBufferEnque
handler = handler =
new Handler(handlerThread.getLooper()) { new Handler(handlerThread.getLooper()) {
@Override @Override
public void handleMessage(@NonNull Message msg) { public void handleMessage(Message msg) {
doHandleMessage(msg); doHandleMessage(msg);
} }
}; };

View File

@ -21,7 +21,6 @@ import android.media.MediaFormat;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@ -184,25 +183,23 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
@Override @Override
public synchronized void onInputBufferAvailable(@NonNull MediaCodec codec, int index) { public synchronized void onInputBufferAvailable(MediaCodec codec, int index) {
mediaCodecAsyncCallback.onInputBufferAvailable(codec, index); mediaCodecAsyncCallback.onInputBufferAvailable(codec, index);
} }
@Override @Override
public synchronized void onOutputBufferAvailable( public synchronized void onOutputBufferAvailable(
@NonNull MediaCodec codec, int index, @NonNull MediaCodec.BufferInfo info) { MediaCodec codec, int index, MediaCodec.BufferInfo info) {
mediaCodecAsyncCallback.onOutputBufferAvailable(codec, index, info); mediaCodecAsyncCallback.onOutputBufferAvailable(codec, index, info);
} }
@Override @Override
public synchronized void onError( public synchronized void onError(MediaCodec codec, MediaCodec.CodecException e) {
@NonNull MediaCodec codec, @NonNull MediaCodec.CodecException e) {
mediaCodecAsyncCallback.onError(codec, e); mediaCodecAsyncCallback.onError(codec, e);
} }
@Override @Override
public synchronized void onOutputFormatChanged( public synchronized void onOutputFormatChanged(MediaCodec codec, MediaFormat format) {
@NonNull MediaCodec codec, @NonNull MediaFormat format) {
mediaCodecAsyncCallback.onOutputFormatChanged(codec, format); mediaCodecAsyncCallback.onOutputFormatChanged(codec, format);
} }

View File

@ -17,7 +17,6 @@ package com.google.android.exoplayer2.mediacodec;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.media.MediaFormat; import android.media.MediaFormat;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@ -120,25 +119,24 @@ import java.util.ArrayDeque;
} }
@Override @Override
public void onInputBufferAvailable(@NonNull MediaCodec mediaCodec, int i) { public void onInputBufferAvailable(MediaCodec mediaCodec, int i) {
availableInputBuffers.add(i); availableInputBuffers.add(i);
} }
@Override @Override
public void onOutputBufferAvailable( public void onOutputBufferAvailable(
@NonNull MediaCodec mediaCodec, int i, @NonNull MediaCodec.BufferInfo bufferInfo) { MediaCodec mediaCodec, int i, MediaCodec.BufferInfo bufferInfo) {
availableOutputBuffers.add(i); availableOutputBuffers.add(i);
bufferInfos.add(bufferInfo); bufferInfos.add(bufferInfo);
} }
@Override @Override
public void onError(@NonNull MediaCodec mediaCodec, @NonNull MediaCodec.CodecException e) { public void onError(MediaCodec mediaCodec, MediaCodec.CodecException e) {
onMediaCodecError(e); onMediaCodecError(e);
} }
@Override @Override
public void onOutputFormatChanged( public void onOutputFormatChanged(MediaCodec mediaCodec, MediaFormat mediaFormat) {
@NonNull MediaCodec mediaCodec, @NonNull MediaFormat mediaFormat) {
availableOutputBuffers.add(MediaCodec.INFO_OUTPUT_FORMAT_CHANGED); availableOutputBuffers.add(MediaCodec.INFO_OUTPUT_FORMAT_CHANGED);
formats.add(mediaFormat); formats.add(mediaFormat);
} }

View File

@ -22,7 +22,6 @@ import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import androidx.annotation.GuardedBy; import androidx.annotation.GuardedBy;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@ -295,15 +294,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// Called by the internal thread. // Called by the internal thread.
@Override @Override
public void onInputBufferAvailable(@NonNull MediaCodec codec, int index) { public void onInputBufferAvailable(MediaCodec codec, int index) {
synchronized (inputBufferLock) { synchronized (inputBufferLock) {
availableInputBuffers.add(index); availableInputBuffers.add(index);
} }
} }
@Override @Override
public void onOutputBufferAvailable( public void onOutputBufferAvailable(MediaCodec codec, int index, MediaCodec.BufferInfo info) {
@NonNull MediaCodec codec, int index, @NonNull MediaCodec.BufferInfo info) {
synchronized (outputBufferLock) { synchronized (outputBufferLock) {
availableOutputBuffers.add(index); availableOutputBuffers.add(index);
bufferInfos.add(info); bufferInfos.add(info);
@ -311,12 +309,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
@Override @Override
public void onError(@NonNull MediaCodec codec, @NonNull MediaCodec.CodecException e) { public void onError(MediaCodec codec, MediaCodec.CodecException e) {
onMediaCodecError(e); onMediaCodecError(e);
} }
@Override @Override
public void onOutputFormatChanged(@NonNull MediaCodec codec, @NonNull MediaFormat format) { public void onOutputFormatChanged(MediaCodec codec, MediaFormat format) {
synchronized (outputBufferLock) { synchronized (outputBufferLock) {
availableOutputBuffers.add(MediaCodec.INFO_OUTPUT_FORMAT_CHANGED); availableOutputBuffers.add(MediaCodec.INFO_OUTPUT_FORMAT_CHANGED);
formats.add(format); formats.add(format);

View File

@ -1156,8 +1156,8 @@ public final class DownloadHelper {
return C.SELECTION_REASON_UNKNOWN; return C.SELECTION_REASON_UNKNOWN;
} }
@Nullable
@Override @Override
@Nullable
public Object getSelectionData() { public Object getSelectionData() {
return null; return null;
} }
@ -1180,8 +1180,8 @@ public final class DownloadHelper {
return 0; return 0;
} }
@Nullable
@Override @Override
@Nullable
public TransferListener getTransferListener() { public TransferListener getTransferListener() {
return null; return null;
} }

View File

@ -693,8 +693,8 @@ public abstract class DownloadService extends Service {
/** /**
* Throws {@link UnsupportedOperationException} because this service is not designed to be bound. * Throws {@link UnsupportedOperationException} because this service is not designed to be bound.
*/ */
@Nullable
@Override @Override
@Nullable
public final IBinder onBind(Intent intent) { public final IBinder onBind(Intent intent) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -91,8 +91,8 @@ import java.util.Map;
return bytesRead; return bytesRead;
} }
@Nullable
@Override @Override
@Nullable
public Uri getUri() { public Uri getUri() {
return upstream.getUri(); return upstream.getUri();
} }

View File

@ -71,8 +71,8 @@ public final class LoopingMediaSource extends CompositeMediaSource<Void> {
return maskingMediaSource.getTag(); return maskingMediaSource.getTag();
} }
@Nullable
@Override @Override
@Nullable
public Timeline getInitialTimeline() { public Timeline getInitialTimeline() {
return loopCount != Integer.MAX_VALUE return loopCount != Integer.MAX_VALUE
? new LoopingTimeline(maskingMediaSource.getTimeline(), loopCount) ? new LoopingTimeline(maskingMediaSource.getTimeline(), loopCount)

View File

@ -83,8 +83,8 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
} }
} }
@Nullable
@Override @Override
@Nullable
public Object getTag() { public Object getTag() {
return mediaSource.getTag(); return mediaSource.getTag();
} }
@ -196,8 +196,8 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
} }
} }
@Nullable
@Override @Override
@Nullable
protected MediaPeriodId getMediaPeriodIdForChildMediaPeriodId( protected MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(
Void id, MediaPeriodId mediaPeriodId) { Void id, MediaPeriodId mediaPeriodId) {
return mediaPeriodId.copyWithPeriodUid(getExternalPeriodUid(mediaPeriodId.periodUid)); return mediaPeriodId.copyWithPeriodUid(getExternalPeriodUid(mediaPeriodId.periodUid));

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.text.cea; package com.google.android.exoplayer2.text.cea;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
@ -185,7 +184,7 @@ import java.util.PriorityQueue;
private long queuedInputBufferCount; private long queuedInputBufferCount;
@Override @Override
public int compareTo(@NonNull CeaInputBuffer other) { public int compareTo(CeaInputBuffer other) {
if (isEndOfStream() != other.isEndOfStream()) { if (isEndOfStream() != other.isEndOfStream()) {
return isEndOfStream() ? 1 : -1; return isEndOfStream() ? 1 : -1;
} }

View File

@ -35,7 +35,6 @@ import android.text.style.StyleSpan;
import android.text.style.TypefaceSpan; import android.text.style.TypefaceSpan;
import android.text.style.UnderlineSpan; import android.text.style.UnderlineSpan;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.span.HorizontalTextInVerticalContextSpan; import com.google.android.exoplayer2.text.span.HorizontalTextInVerticalContextSpan;
@ -866,7 +865,7 @@ public final class WebvttCueParser {
} }
@Override @Override
public int compareTo(@NonNull StyleMatch another) { public int compareTo(StyleMatch another) {
return this.score - another.score; return this.score - another.score;
} }

View File

@ -110,8 +110,8 @@ public final class ResolvingDataSource implements DataSource {
return upstreamDataSource.read(buffer, offset, readLength); return upstreamDataSource.read(buffer, offset, readLength);
} }
@Nullable
@Override @Override
@Nullable
public Uri getUri() { public Uri getUri() {
@Nullable Uri reportedUri = upstreamDataSource.getUri(); @Nullable Uri reportedUri = upstreamDataSource.getUri();
return reportedUri == null ? null : resolver.resolveReportedUri(reportedUri); return reportedUri == null ? null : resolver.resolveReportedUri(reportedUri);

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.upstream.cache; package com.google.android.exoplayer2.upstream.cache;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import java.io.File; import java.io.File;
@ -95,7 +94,7 @@ public class CacheSpan implements Comparable<CacheSpan> {
} }
@Override @Override
public int compareTo(@NonNull CacheSpan another) { public int compareTo(CacheSpan another) {
if (!key.equals(another.key)) { if (!key.equals(another.key)) {
return key.compareTo(another.key); return key.compareTo(another.key);
} }

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.upstream.cache; package com.google.android.exoplayer2.upstream.cache;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.extractor.ChunkIndex; import com.google.android.exoplayer2.extractor.ChunkIndex;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
@ -196,7 +195,7 @@ public final class CachedRegionTracker implements Cache.Listener {
} }
@Override @Override
public int compareTo(@NonNull Region another) { public int compareTo(Region another) {
return Util.compareLong(startOffset, another.startOffset); return Util.compareLong(startOffset, another.startOffset);
} }

View File

@ -16,7 +16,6 @@
package com.google.android.exoplayer2.upstream.cache; package com.google.android.exoplayer2.upstream.cache;
import android.os.ConditionVariable; import android.os.ConditionVariable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread; import androidx.annotation.WorkerThread;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
@ -332,7 +331,6 @@ public final class SimpleCache implements Cache {
} }
} }
@NonNull
@Override @Override
public synchronized NavigableSet<CacheSpan> getCachedSpans(String key) { public synchronized NavigableSet<CacheSpan> getCachedSpans(String key) {
Assertions.checkState(!released); Assertions.checkState(!released);

View File

@ -3291,8 +3291,8 @@ public final class ExoPlayerTest {
return false; return false;
} }
@Nullable
@Override @Override
@Nullable
public Timeline getInitialTimeline() { public Timeline getInitialTimeline() {
return Timeline.EMPTY; return Timeline.EMPTY;
} }

View File

@ -130,8 +130,8 @@ public class DownloadServiceDashTest {
return dashDownloadManager; return dashDownloadManager;
} }
@Nullable
@Override @Override
@Nullable
protected Scheduler getScheduler() { protected Scheduler getScheduler() {
return null; return null;
} }

View File

@ -135,8 +135,8 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact
return new SparseArray<>(); return new SparseArray<>();
} }
@Nullable
@Override @Override
@Nullable
public TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo) { public TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo) {
switch (streamType) { switch (streamType) {
case TsExtractor.TS_STREAM_TYPE_MPA: case TsExtractor.TS_STREAM_TYPE_MPA:

View File

@ -138,8 +138,8 @@ public final class TsExtractorTest {
} }
} }
@Nullable
@Override @Override
@Nullable
public TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo) { public TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo) {
if (provideCustomEsReader && streamType == 3) { if (provideCustomEsReader && streamType == 3) {
esReader = new CustomEsReader(esInfo.language); esReader = new CustomEsReader(esInfo.language);

View File

@ -186,8 +186,8 @@ public class FakeDataSource extends BaseDataSource {
} }
} }
@Nullable
@Override @Override
@Nullable
public final Uri getUri() { public final Uri getUri() {
return uri; return uri;
} }

View File

@ -119,8 +119,8 @@ public class FakeMediaSource extends BaseMediaSource {
return timeline.getWindow(0, new Timeline.Window()).tag; return timeline.getWindow(0, new Timeline.Window()).tag;
} }
@Nullable
@Override @Override
@Nullable
public Timeline getInitialTimeline() { public Timeline getInitialTimeline() {
return timeline == null || timeline == Timeline.EMPTY || timeline.getWindowCount() == 1 return timeline == null || timeline == Timeline.EMPTY || timeline.getWindowCount() == 1
? null ? null

View File

@ -231,8 +231,8 @@ public final class MediaPeriodAsserts {
return C.SELECTION_REASON_UNKNOWN; return C.SELECTION_REASON_UNKNOWN;
} }
@Nullable
@Override @Override
@Nullable
public Object getSelectionData() { public Object getSelectionData() {
return null; return null;
} }