From f0b88a85b90a267a254beb3b94ddba7460e17953 Mon Sep 17 00:00:00 2001 From: David Motsonashvili Date: Wed, 31 Jul 2024 08:06:09 -0700 Subject: [PATCH 1/3] remove javax.annotation.Nonnull from files containing a different NonNull annotation --- .../firebase/remoteconfig/bandwagoner/RealtimeFragment.java | 2 +- .../google/firebase/remoteconfig/ConfigUpdateListener.java | 3 +-- .../remoteconfig/FirebaseRemoteConfigServerException.java | 5 ++--- .../firebase/remoteconfig/FirebaseRemoteConfigTest.java | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner/RealtimeFragment.java b/firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner/RealtimeFragment.java index 2b08a7607c1..781324b6444 100644 --- a/firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner/RealtimeFragment.java +++ b/firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner/RealtimeFragment.java @@ -94,7 +94,7 @@ private void toggleRealtime(View view, Boolean isChecked) { frc.addOnConfigUpdateListener( new ConfigUpdateListener() { @Override - public void onUpdate(ConfigUpdate configUpdate) { + public void onUpdate(@NonNull ConfigUpdate configUpdate) { Log.d(TAG, String.join(", ", configUpdate.getUpdatedKeys())); updatedParamsText.setText(String.join(", ", configUpdate.getUpdatedKeys())); } diff --git a/firebase-config/src/main/java/com/google/firebase/remoteconfig/ConfigUpdateListener.java b/firebase-config/src/main/java/com/google/firebase/remoteconfig/ConfigUpdateListener.java index 9300963a1d6..7389c5aad86 100644 --- a/firebase-config/src/main/java/com/google/firebase/remoteconfig/ConfigUpdateListener.java +++ b/firebase-config/src/main/java/com/google/firebase/remoteconfig/ConfigUpdateListener.java @@ -15,7 +15,6 @@ package com.google.firebase.remoteconfig; import androidx.annotation.NonNull; -import javax.annotation.Nonnull; /** * Event listener interface for real-time Remote Config updates. Implement {@code @@ -38,5 +37,5 @@ public interface ConfigUpdateListener { * * @param error A {@link FirebaseRemoteConfigException} with information about the error. */ - void onError(@Nonnull FirebaseRemoteConfigException error); + void onError(@NonNull FirebaseRemoteConfigException error); } diff --git a/firebase-config/src/main/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigServerException.java b/firebase-config/src/main/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigServerException.java index c2e559358b6..bde7d2f2d1a 100644 --- a/firebase-config/src/main/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigServerException.java +++ b/firebase-config/src/main/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigServerException.java @@ -16,7 +16,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import javax.annotation.Nonnull; /** * A Firebase Remote Config internal issue caused by an interaction with the Firebase Remote Config @@ -46,7 +45,7 @@ public FirebaseRemoteConfigServerException( * Creates a Firebase Remote Config server exception with the given message and {@code * FirebaseRemoteConfigException} code. */ - public FirebaseRemoteConfigServerException(@NonNull String detailMessage, @Nonnull Code code) { + public FirebaseRemoteConfigServerException(@NonNull String detailMessage, @NonNull Code code) { super(detailMessage, code); this.httpStatusCode = -1; } @@ -56,7 +55,7 @@ public FirebaseRemoteConfigServerException(@NonNull String detailMessage, @Nonnu * {@code FirebaseRemoteConfigException} code. */ public FirebaseRemoteConfigServerException( - int httpStatusCode, @NonNull String detailMessage, @Nonnull Code code) { + int httpStatusCode, @NonNull String detailMessage, @NonNull Code code) { super(detailMessage, code); this.httpStatusCode = httpStatusCode; } diff --git a/firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java b/firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java index 3618fd0ea27..81f292a4c2b 100644 --- a/firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java +++ b/firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java @@ -316,7 +316,7 @@ public void setUp() throws Exception { ConfigUpdateListener listener = new ConfigUpdateListener() { @Override - public void onUpdate(ConfigUpdate configUpdate) { + public void onUpdate(@NonNull ConfigUpdate configUpdate) { mockOnUpdateListener.onUpdate(configUpdate); } @@ -1757,7 +1757,7 @@ private void flushScheduledTasks() throws InterruptedException { private ConfigUpdateListener generateEmptyRealtimeListener() { return new ConfigUpdateListener() { @Override - public void onUpdate(ConfigUpdate configUpdate) {} + public void onUpdate(@NonNull ConfigUpdate configUpdate) {} @Override public void onError(@NonNull FirebaseRemoteConfigException error) {} From 7861fc7f8476031a0c712f87570aad49e273680a Mon Sep 17 00:00:00 2001 From: David Motsonashvili Date: Tue, 6 Aug 2024 10:27:19 -0700 Subject: [PATCH 2/3] fix duplicate annotation in the other files --- .../firestore/AggregateQuerySnapshot.java | 21 +++++++++---------- .../local/MemoryRemoteDocumentCache.java | 5 ++--- .../model/ProtoMarshallerClient.java | 14 ++++++------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/AggregateQuerySnapshot.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/AggregateQuerySnapshot.java index 8f1ce3985c1..a5452199e0f 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/AggregateQuerySnapshot.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/AggregateQuerySnapshot.java @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.Map; import java.util.Objects; -import javax.annotation.Nonnull; /** * The results of executing an {@link AggregateQuery}. @@ -33,9 +32,9 @@ */ public class AggregateQuerySnapshot { - @Nonnull private final AggregateQuery query; + @NonNull private final AggregateQuery query; - @Nonnull private final Map data; + @NonNull private final Map data; AggregateQuerySnapshot(@NonNull AggregateQuery query, @NonNull Map data) { checkNotNull(query); @@ -73,7 +72,7 @@ public long getCount() { * @return The result of the given aggregation. */ @Nullable - public Object get(@Nonnull AggregateField aggregateField) { + public Object get(@NonNull AggregateField aggregateField) { return getInternal(aggregateField); } @@ -83,7 +82,7 @@ public Object get(@Nonnull AggregateField aggregateField) { * @param countAggregateField The count aggregation for which the value is requested. * @return The result of the given count aggregation. */ - public long get(@Nonnull AggregateField.CountAggregateField countAggregateField) { + public long get(@NonNull AggregateField.CountAggregateField countAggregateField) { Long value = getLong(countAggregateField); if (value == null) { throw new IllegalArgumentException( @@ -102,7 +101,7 @@ public long get(@Nonnull AggregateField.CountAggregateField countAggregateField) * @return The result of the given average aggregation. */ @Nullable - public Double get(@Nonnull AggregateField.AverageAggregateField averageAggregateField) { + public Double get(@NonNull AggregateField.AverageAggregateField averageAggregateField) { return getDouble(averageAggregateField); } @@ -116,7 +115,7 @@ public Double get(@Nonnull AggregateField.AverageAggregateField averageAggregate * @return The result of the given average aggregation as a double. */ @Nullable - public Double getDouble(@Nonnull AggregateField aggregateField) { + public Double getDouble(@NonNull AggregateField aggregateField) { Number val = getTypedValue(aggregateField, Number.class); return val != null ? val.doubleValue() : null; } @@ -130,13 +129,13 @@ public Double getDouble(@Nonnull AggregateField aggregateField) { * @return The result of the given average aggregation as a long. */ @Nullable - public Long getLong(@Nonnull AggregateField aggregateField) { + public Long getLong(@NonNull AggregateField aggregateField) { Number val = getTypedValue(aggregateField, Number.class); return val != null ? val.longValue() : null; } @Nullable - private Object getInternal(@Nonnull AggregateField aggregateField) { + private Object getInternal(@NonNull AggregateField aggregateField) { if (!data.containsKey(aggregateField.getAlias())) { throw new IllegalArgumentException( "'" @@ -154,14 +153,14 @@ private Object getInternal(@Nonnull AggregateField aggregateField) { } @Nullable - private T getTypedValue(@Nonnull AggregateField aggregateField, Class clazz) { + private T getTypedValue(@NonNull AggregateField aggregateField, Class clazz) { Object value = getInternal(aggregateField); return castTypedValue(value, aggregateField, clazz); } @Nullable private T castTypedValue( - Object value, @Nonnull AggregateField aggregateField, Class clazz) { + Object value, @NonNull AggregateField aggregateField, Class clazz) { if (value == null) { return null; } else if (!clazz.isInstance(value)) { diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/local/MemoryRemoteDocumentCache.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/local/MemoryRemoteDocumentCache.java index 6bd043f6e82..36f028f4309 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/local/MemoryRemoteDocumentCache.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/local/MemoryRemoteDocumentCache.java @@ -31,7 +31,6 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; -import javax.annotation.Nonnull; /** In-memory cache of remote documents. */ final class MemoryRemoteDocumentCache implements RemoteDocumentCache { @@ -101,7 +100,7 @@ public Map getAll( public Map getDocumentsMatchingQuery( Query query, IndexOffset offset, - @Nonnull Set mutatedKeys, + @NonNull Set mutatedKeys, @Nullable QueryContext context) { Map result = new HashMap<>(); @@ -142,7 +141,7 @@ public Map getDocumentsMatchingQuery( @Override public Map getDocumentsMatchingQuery( - Query query, IndexOffset offset, @Nonnull Set mutatedKeys) { + Query query, IndexOffset offset, @NonNull Set mutatedKeys) { return getDocumentsMatchingQuery(query, offset, mutatedKeys, /*context*/ null); } diff --git a/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/model/ProtoMarshallerClient.java b/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/model/ProtoMarshallerClient.java index b16b6213171..91a37c17e8b 100644 --- a/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/model/ProtoMarshallerClient.java +++ b/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/model/ProtoMarshallerClient.java @@ -16,12 +16,12 @@ import android.text.TextUtils; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import com.google.common.base.Preconditions; import com.google.firebase.inappmessaging.MessagesProto; import com.google.firebase.inappmessaging.internal.Logging; import java.util.Map; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; @@ -38,7 +38,7 @@ public class ProtoMarshallerClient { @Inject ProtoMarshallerClient() {} - @Nonnull + @NonNull private static ModalMessage.Builder from(MessagesProto.ModalMessage in) { ModalMessage.Builder builder = ModalMessage.builder(); @@ -65,7 +65,7 @@ private static ModalMessage.Builder from(MessagesProto.ModalMessage in) { return builder; } - @Nonnull + @NonNull private static ImageOnlyMessage.Builder from(MessagesProto.ImageOnlyMessage in) { ImageOnlyMessage.Builder builder = ImageOnlyMessage.builder(); @@ -80,7 +80,7 @@ private static ImageOnlyMessage.Builder from(MessagesProto.ImageOnlyMessage in) return builder; } - @Nonnull + @NonNull private static BannerMessage.Builder from(MessagesProto.BannerMessage in) { BannerMessage.Builder builder = BannerMessage.builder(); @@ -107,7 +107,7 @@ private static BannerMessage.Builder from(MessagesProto.BannerMessage in) { return builder; } - @Nonnull + @NonNull private static CardMessage.Builder from(MessagesProto.CardMessage in) { CardMessage.Builder builder = CardMessage.builder(); @@ -207,7 +207,7 @@ private static Text decode(MessagesProto.Text in) { /** Tranform {@link MessagesProto.Content} proto to an {@link InAppMessage} value object */ public static InAppMessage decode( - @Nonnull MessagesProto.Content in, + @NonNull MessagesProto.Content in, @NonNull String campaignId, @NonNull String campaignName, boolean isTestMessage, From 5eb5192c7a02c21df176c792e2a67d0f0aa27221 Mon Sep 17 00:00:00 2001 From: David Motsonashvili Date: Tue, 24 Sep 2024 09:01:55 -0700 Subject: [PATCH 3/3] format --- .../firebase/inappmessaging/model/ProtoMarshallerClient.java | 1 - 1 file changed, 1 deletion(-) diff --git a/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/model/ProtoMarshallerClient.java b/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/model/ProtoMarshallerClient.java index 91a37c17e8b..2ea790eebce 100644 --- a/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/model/ProtoMarshallerClient.java +++ b/firebase-inappmessaging/src/main/java/com/google/firebase/inappmessaging/model/ProtoMarshallerClient.java @@ -17,7 +17,6 @@ import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; - import com.google.common.base.Preconditions; import com.google.firebase.inappmessaging.MessagesProto; import com.google.firebase.inappmessaging.internal.Logging;