diff options
author | Google Java Core Libraries <java-team-github-bot@google.com> | 2021-09-23 08:58:22 -0700 |
---|---|---|
committer | Google Java Core Libraries <java-core-libraries-team+copybara@google.com> | 2021-09-23 09:01:10 -0700 |
commit | f9b25b423ac6c7201d77387efe079ff540954de2 (patch) | |
tree | c8a7bcaf26798be2bf3f29112f991adaad194fd0 | |
parent | 4beff962f36846fbfc8ff1de89f0a63716ad45d2 (diff) | |
download | guava-f9b25b423ac6c7201d77387efe079ff540954de2.tar.gz |
Chuck a few more `@DoNotCall`s around Guava
RELNOTES=n/a
PiperOrigin-RevId: 398498984
4 files changed, 53 insertions, 10 deletions
diff --git a/android/guava/src/com/google/common/collect/ImmutableMultimap.java b/android/guava/src/com/google/common/collect/ImmutableMultimap.java index 605c28c27..04a6c4a41 100644 --- a/android/guava/src/com/google/common/collect/ImmutableMultimap.java +++ b/android/guava/src/com/google/common/collect/ImmutableMultimap.java @@ -25,6 +25,7 @@ import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.DoNotMock; import com.google.j2objc.annotations.Weak; import com.google.j2objc.annotations.WeakOuter; @@ -364,6 +365,10 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") + // DoNotCall wants this to be final, but we want to override it to return more specific types. + // Inheritance is closed, and all subtypes are @DoNotCall, so this is safe to suppress. + @SuppressWarnings("DoNotCall") public ImmutableCollection<V> removeAll(@CheckForNull Object key) { throw new UnsupportedOperationException(); } @@ -377,6 +382,10 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") + // DoNotCall wants this to be final, but we want to override it to return more specific types. + // Inheritance is closed, and all subtypes are @DoNotCall, so this is safe to suppress. + @SuppressWarnings("DoNotCall") public ImmutableCollection<V> replaceValues(K key, Iterable<? extends V> values) { throw new UnsupportedOperationException(); } @@ -389,7 +398,8 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V */ @Deprecated @Override - public void clear() { + @DoNotCall("Always throws UnsupportedOperationException") + public final void clear() { throw new UnsupportedOperationException(); } @@ -418,7 +428,8 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override - public boolean put(K key, V value) { + @DoNotCall("Always throws UnsupportedOperationException") + public final boolean put(K key, V value) { throw new UnsupportedOperationException(); } @@ -431,7 +442,8 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override - public boolean putAll(K key, Iterable<? extends V> values) { + @DoNotCall("Always throws UnsupportedOperationException") + public final boolean putAll(K key, Iterable<? extends V> values) { throw new UnsupportedOperationException(); } @@ -444,7 +456,8 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override - public boolean putAll(Multimap<? extends K, ? extends V> multimap) { + @DoNotCall("Always throws UnsupportedOperationException") + public final boolean putAll(Multimap<? extends K, ? extends V> multimap) { throw new UnsupportedOperationException(); } @@ -457,7 +470,8 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override - public boolean remove(@CheckForNull Object key, @CheckForNull Object value) { + @DoNotCall("Always throws UnsupportedOperationException") + public final boolean remove(@CheckForNull Object key, @CheckForNull Object value) { throw new UnsupportedOperationException(); } diff --git a/android/guava/src/com/google/common/collect/Sets.java b/android/guava/src/com/google/common/collect/Sets.java index 7b4f98fc0..dde21cb37 100644 --- a/android/guava/src/com/google/common/collect/Sets.java +++ b/android/guava/src/com/google/common/collect/Sets.java @@ -28,6 +28,7 @@ import com.google.common.base.Predicates; import com.google.common.collect.Collections2.FilteredCollection; import com.google.common.math.IntMath; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.errorprone.annotations.DoNotCall; import java.io.Serializable; import java.util.AbstractSet; import java.util.Arrays; @@ -580,6 +581,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean add(@ParametricNullness E e) { throw new UnsupportedOperationException(); } @@ -593,6 +595,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean remove(@CheckForNull Object object) { throw new UnsupportedOperationException(); } @@ -606,6 +609,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean addAll(Collection<? extends E> newElements) { throw new UnsupportedOperationException(); } @@ -619,6 +623,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean removeAll(Collection<?> oldElements) { throw new UnsupportedOperationException(); } @@ -632,6 +637,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean retainAll(Collection<?> elementsToKeep) { throw new UnsupportedOperationException(); } @@ -644,6 +650,7 @@ public final class Sets { */ @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final void clear() { throw new UnsupportedOperationException(); } diff --git a/guava/src/com/google/common/collect/ImmutableMultimap.java b/guava/src/com/google/common/collect/ImmutableMultimap.java index e53f6e940..5dfbb9bca 100644 --- a/guava/src/com/google/common/collect/ImmutableMultimap.java +++ b/guava/src/com/google/common/collect/ImmutableMultimap.java @@ -25,6 +25,7 @@ import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.errorprone.annotations.DoNotCall; import com.google.errorprone.annotations.DoNotMock; import com.google.j2objc.annotations.Weak; import com.google.j2objc.annotations.WeakOuter; @@ -366,6 +367,10 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") + // DoNotCall wants this to be final, but we want to override it to return more specific types. + // Inheritance is closed, and all subtypes are @DoNotCall, so this is safe to suppress. + @SuppressWarnings("DoNotCall") public ImmutableCollection<V> removeAll(@CheckForNull Object key) { throw new UnsupportedOperationException(); } @@ -379,6 +384,10 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") + // DoNotCall wants this to be final, but we want to override it to return more specific types. + // Inheritance is closed, and all subtypes are @DoNotCall, so this is safe to suppress. + @SuppressWarnings("DoNotCall") public ImmutableCollection<V> replaceValues(K key, Iterable<? extends V> values) { throw new UnsupportedOperationException(); } @@ -391,7 +400,8 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V */ @Deprecated @Override - public void clear() { + @DoNotCall("Always throws UnsupportedOperationException") + public final void clear() { throw new UnsupportedOperationException(); } @@ -420,7 +430,8 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override - public boolean put(K key, V value) { + @DoNotCall("Always throws UnsupportedOperationException") + public final boolean put(K key, V value) { throw new UnsupportedOperationException(); } @@ -433,7 +444,8 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override - public boolean putAll(K key, Iterable<? extends V> values) { + @DoNotCall("Always throws UnsupportedOperationException") + public final boolean putAll(K key, Iterable<? extends V> values) { throw new UnsupportedOperationException(); } @@ -446,7 +458,8 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override - public boolean putAll(Multimap<? extends K, ? extends V> multimap) { + @DoNotCall("Always throws UnsupportedOperationException") + public final boolean putAll(Multimap<? extends K, ? extends V> multimap) { throw new UnsupportedOperationException(); } @@ -459,7 +472,8 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V @CanIgnoreReturnValue @Deprecated @Override - public boolean remove(@CheckForNull Object key, @CheckForNull Object value) { + @DoNotCall("Always throws UnsupportedOperationException") + public final boolean remove(@CheckForNull Object key, @CheckForNull Object value) { throw new UnsupportedOperationException(); } diff --git a/guava/src/com/google/common/collect/Sets.java b/guava/src/com/google/common/collect/Sets.java index a54aef617..5338bd244 100644 --- a/guava/src/com/google/common/collect/Sets.java +++ b/guava/src/com/google/common/collect/Sets.java @@ -28,6 +28,7 @@ import com.google.common.base.Predicates; import com.google.common.collect.Collections2.FilteredCollection; import com.google.common.math.IntMath; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.errorprone.annotations.DoNotCall; import java.io.Serializable; import java.util.AbstractSet; import java.util.Arrays; @@ -594,6 +595,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean add(@ParametricNullness E e) { throw new UnsupportedOperationException(); } @@ -607,6 +609,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean remove(@CheckForNull Object object) { throw new UnsupportedOperationException(); } @@ -620,6 +623,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean addAll(Collection<? extends E> newElements) { throw new UnsupportedOperationException(); } @@ -633,6 +637,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean removeAll(Collection<?> oldElements) { throw new UnsupportedOperationException(); } @@ -646,6 +651,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean removeIf(java.util.function.Predicate<? super E> filter) { throw new UnsupportedOperationException(); } @@ -659,6 +665,7 @@ public final class Sets { @CanIgnoreReturnValue @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final boolean retainAll(Collection<?> elementsToKeep) { throw new UnsupportedOperationException(); } @@ -671,6 +678,7 @@ public final class Sets { */ @Deprecated @Override + @DoNotCall("Always throws UnsupportedOperationException") public final void clear() { throw new UnsupportedOperationException(); } |