Skip to content

Commit

Permalink
Apply or suppress suggestions to use @InlineMe.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 711473023
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jan 2, 2025
1 parent c146772 commit 4559277
Show file tree
Hide file tree
Showing 35 changed files with 158 additions and 2 deletions.
10 changes: 10 additions & 0 deletions android/guava/src/com/google/common/base/CharMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.InlineMe;
import com.google.errorprone.annotations.InlineMeValidationDisabled;
import java.util.Arrays;
import java.util.BitSet;

Expand Down Expand Up @@ -905,8 +907,16 @@ private String finishCollapseFrom(
* @deprecated Provided only to satisfy the {@link Predicate} interface; use {@link #matches}
* instead.
*/
@InlineMe(replacement = "this.matches(character)")
@Deprecated
@Override
/*
* We can't compatibly make this `final` now (even after devising a way for `ForPredicate`, which
* currently overrides it, to keep the null check that it inserts).
*/
@InlineMeValidationDisabled(
"While apply() is not final, the inlining is still safe because all known overrides of"
+ " apply() call matches().")
public boolean apply(Character character) {
return matches(character);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.google.common.collect;

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.InlineMe;
import java.util.Comparator;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -230,6 +231,7 @@ public int result() {
* negated or reversed, undo the negation or reversal and use {@link #compareTrueFirst}.
* @since 19.0
*/
@InlineMe(replacement = "this.compareFalseFirst(left, right)")
@Deprecated
public final ComparisonChain compare(Boolean left, Boolean right) {
return compareFalseFirst(left, right);
Expand Down
4 changes: 4 additions & 0 deletions android/guava/src/com/google/common/collect/Iterables.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.InlineMe;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
Expand Down Expand Up @@ -82,6 +83,9 @@ private Iterables() {}
* @deprecated no need to use this
* @since 10.0
*/
@InlineMe(
replacement = "checkNotNull(iterable)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <E> Iterable<E> unmodifiableIterable(ImmutableCollection<E> iterable) {
return checkNotNull(iterable);
Expand Down
7 changes: 7 additions & 0 deletions android/guava/src/com/google/common/collect/Iterators.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.google.common.base.Predicate;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.InlineMe;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -153,6 +154,9 @@ public T next() {
* @deprecated no need to use this
* @since 10.0
*/
@InlineMe(
replacement = "checkNotNull(iterator)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <T extends @Nullable Object> UnmodifiableIterator<T> unmodifiableIterator(
UnmodifiableIterator<T> iterator) {
Expand Down Expand Up @@ -1272,6 +1276,9 @@ public E peek() {
* @deprecated no need to use this
* @since 10.0
*/
@InlineMe(
replacement = "checkNotNull(iterator)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <T extends @Nullable Object> PeekingIterator<T> peekingIterator(
PeekingIterator<T> iterator) {
Expand Down
10 changes: 10 additions & 0 deletions android/guava/src/com/google/common/collect/Multimaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.common.base.Supplier;
import com.google.common.collect.Maps.EntryTransformer;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.InlineMe;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.Weak;
import com.google.j2objc.annotations.WeakOuter;
Expand Down Expand Up @@ -667,6 +668,9 @@ Multimap<K, V> unmodifiableMultimap(Multimap<K, V> delegate) {
* @deprecated no need to use this
* @since 10.0
*/
@InlineMe(
replacement = "checkNotNull(delegate)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <K, V> Multimap<K, V> unmodifiableMultimap(ImmutableMultimap<K, V> delegate) {
return checkNotNull(delegate);
Expand Down Expand Up @@ -927,6 +931,9 @@ SetMultimap<K, V> unmodifiableSetMultimap(SetMultimap<K, V> delegate) {
* @deprecated no need to use this
* @since 10.0
*/
@InlineMe(
replacement = "checkNotNull(delegate)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <K, V> SetMultimap<K, V> unmodifiableSetMultimap(
ImmutableSetMultimap<K, V> delegate) {
Expand Down Expand Up @@ -1008,6 +1015,9 @@ ListMultimap<K, V> unmodifiableListMultimap(ListMultimap<K, V> delegate) {
* @deprecated no need to use this
* @since 10.0
*/
@InlineMe(
replacement = "checkNotNull(delegate)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <K, V> ListMultimap<K, V> unmodifiableListMultimap(
ImmutableListMultimap<K, V> delegate) {
Expand Down
4 changes: 4 additions & 0 deletions android/guava/src/com/google/common/collect/Multisets.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.common.math.IntMath;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.InlineMe;
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.io.Serializable;
import java.util.Arrays;
Expand Down Expand Up @@ -117,6 +118,9 @@ private Multisets() {}
* @deprecated no need to use this
* @since 10.0
*/
@InlineMe(
replacement = "checkNotNull(multiset)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <E> Multiset<E> unmodifiableMultiset(ImmutableMultiset<E> multiset) {
return checkNotNull(multiset);
Expand Down
12 changes: 12 additions & 0 deletions android/guava/src/com/google/common/collect/Ordering.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.errorprone.annotations.InlineMe;
import com.google.errorprone.annotations.InlineMeValidationDisabled;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -199,6 +201,9 @@ public static <C extends Comparable> Ordering<C> natural() {
*
* @deprecated no need to use this
*/
@InlineMe(
replacement = "checkNotNull(ordering)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@GwtCompatible(serializable = true)
@Deprecated
public static <T extends @Nullable Object> Ordering<T> from(Ordering<T> ordering) {
Expand Down Expand Up @@ -949,6 +954,13 @@ public boolean isStrictlyOrdered(Iterable<? extends T> iterable) {
* @param key the key to be searched for
* @deprecated Use {@link Collections#binarySearch(List, Object, Comparator)} directly.
*/
@InlineMe(
replacement = "Collections.binarySearch(sortedList, key, this)",
imports = "java.util.Collections")
// We can't compatibly make this `final` now.
@InlineMeValidationDisabled(
"While binarySearch() is not final, the inlining is still safe as long as any overrides"
+ " follow the contract.")
@Deprecated
public int binarySearch(
List<? extends T> sortedList, @ParametricNullness T key) {
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/collect/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.common.base.Equivalence;
import com.google.common.base.Predicate;
import com.google.errorprone.annotations.Immutable;
import com.google.errorprone.annotations.InlineMe;
import java.io.Serializable;
import java.util.Comparator;
import java.util.Iterator;
Expand Down Expand Up @@ -412,6 +413,7 @@ public boolean contains(C value) {
* @deprecated Provided only to satisfy the {@link Predicate} interface; use {@link #contains}
* instead.
*/
@InlineMe(replacement = "this.contains(input)")
@Deprecated
@Override
public boolean apply(C input) {
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/collect/Sets.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.common.math.IntMath;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotCall;
import com.google.errorprone.annotations.InlineMe;
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.io.Serializable;
import java.util.AbstractSet;
Expand Down Expand Up @@ -572,6 +573,7 @@ private static <E extends Enum<E>> EnumSet<E> makeComplementByHand(
* @throws IllegalArgumentException if {@code map} is not empty
* @deprecated Use {@link Collections#newSetFromMap} instead.
*/
@InlineMe(replacement = "Collections.newSetFromMap(map)", imports = "java.util.Collections")
@Deprecated
public static <E extends @Nullable Object> Set<E> newSetFromMap(
Map<E, Boolean> map) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Supplier;
import com.google.errorprone.annotations.InlineMe;
import java.io.Serializable;
import java.util.Comparator;
import java.util.Iterator;
Expand Down Expand Up @@ -136,8 +137,11 @@ public static <R, C, V> TreeBasedTable<R, C, V> create(TreeBasedTable<R, C, ? ex
*
* @deprecated Use {@code table.rowKeySet().comparator()} instead.
*/
@InlineMe(
replacement = "requireNonNull(this.rowKeySet().comparator())",
staticImports = "java.util.Objects.requireNonNull")
@Deprecated
public Comparator<? super R> rowComparator() {
public final Comparator<? super R> rowComparator() {
/*
* requireNonNull is safe because the factories require non-null Comparators, which they pass on
* to the backing collections.
Expand Down
4 changes: 4 additions & 0 deletions android/guava/src/com/google/common/graph/ImmutableGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.common.graph.GraphConstants.Presence;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Immutable;
import com.google.errorprone.annotations.InlineMe;

/**
* A {@link Graph} whose elements and structural relationships will never change. Instances of this
Expand Down Expand Up @@ -67,6 +68,9 @@ public static <N> ImmutableGraph<N> copyOf(Graph<N> graph) {
*
* @deprecated no need to use this
*/
@InlineMe(
replacement = "checkNotNull(graph)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <N> ImmutableGraph<N> copyOf(ImmutableGraph<N> graph) {
return checkNotNull(graph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.common.collect.Maps;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Immutable;
import com.google.errorprone.annotations.InlineMe;
import java.util.Map;

/**
Expand Down Expand Up @@ -65,6 +66,9 @@ public static <N, E> ImmutableNetwork<N, E> copyOf(Network<N, E> network) {
*
* @deprecated no need to use this
*/
@InlineMe(
replacement = "checkNotNull(network)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <N, E> ImmutableNetwork<N, E> copyOf(ImmutableNetwork<N, E> network) {
return checkNotNull(network);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.common.collect.Maps;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Immutable;
import com.google.errorprone.annotations.InlineMe;

/**
* A {@link ValueGraph} whose elements and structural relationships will never change. Instances of
Expand Down Expand Up @@ -62,6 +63,9 @@ public static <N, V> ImmutableValueGraph<N, V> copyOf(ValueGraph<N, V> graph) {
*
* @deprecated no need to use this
*/
@InlineMe(
replacement = "checkNotNull(graph)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <N, V> ImmutableValueGraph<N, V> copyOf(ImmutableValueGraph<N, V> graph) {
return checkNotNull(graph);
Expand Down
2 changes: 2 additions & 0 deletions android/guava/src/com/google/common/hash/BloomFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.common.primitives.SignedBytes;
import com.google.common.primitives.UnsignedBytes;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.InlineMe;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -159,6 +160,7 @@ public boolean mightContain(@ParametricNullness T object) {
* @deprecated Provided only to satisfy the {@link Predicate} interface; use {@link #mightContain}
* instead.
*/
@InlineMe(replacement = "this.mightContain(input)")
@Deprecated
@Override
public boolean apply(@ParametricNullness T input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected ExecutionError() {}
* calling {@link #initCause} later, so it is not quite equivalent to using a constructor that
* omits the cause.
*/
@SuppressWarnings("InlineMeSuggester") // b/387265535
@Deprecated
protected ExecutionError(@Nullable String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.common.base.Function;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import com.google.errorprone.annotations.InlineMe;
import java.time.Duration;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
Expand Down Expand Up @@ -141,6 +142,9 @@ public final boolean cancel(boolean mayInterruptIfRunning) {
* @deprecated no need to use this
* @since 28.0
*/
@InlineMe(
replacement = "checkNotNull(future)",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
@Deprecated
public static <V extends @Nullable Object> FluentFuture<V> from(FluentFuture<V> future) {
return checkNotNull(future);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ protected UncheckedExecutionException() {}
* anyone from calling {@link #initCause} later, so it is not quite equivalent to using a
* constructor that omits the cause.
*/
@SuppressWarnings("InlineMeSuggester") // b/387265535
@Deprecated
protected UncheckedExecutionException(@Nullable String message) {
super(message);
Expand Down
10 changes: 10 additions & 0 deletions guava/src/com/google/common/base/CharMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.InlineMe;
import com.google.errorprone.annotations.InlineMeValidationDisabled;
import java.util.Arrays;
import java.util.BitSet;

Expand Down Expand Up @@ -905,8 +907,16 @@ private String finishCollapseFrom(
* @deprecated Provided only to satisfy the {@link Predicate} interface; use {@link #matches}
* instead.
*/
@InlineMe(replacement = "this.matches(character)")
@Deprecated
@Override
/*
* We can't compatibly make this `final` now (even after devising a way for `ForPredicate`, which
* currently overrides it, to keep the null check that it inserts).
*/
@InlineMeValidationDisabled(
"While apply() is not final, the inlining is still safe because all known overrides of"
+ " apply() call matches().")
public boolean apply(Character character) {
return matches(character);
}
Expand Down
2 changes: 2 additions & 0 deletions guava/src/com/google/common/base/Equivalence.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.errorprone.annotations.ForOverride;
import com.google.errorprone.annotations.InlineMe;
import java.io.Serializable;
import java.util.function.BiPredicate;
import org.jspecify.annotations.NonNull;
Expand Down Expand Up @@ -75,6 +76,7 @@ public final boolean equivalent(@Nullable T a, @Nullable T b) {
* instead.
* @since 21.0
*/
@InlineMe(replacement = "this.equivalent(t, u)")
@Deprecated
@Override
public final boolean test(@Nullable T t, @Nullable T u) {
Expand Down
2 changes: 2 additions & 0 deletions guava/src/com/google/common/collect/ComparisonChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.common.annotations.GwtCompatible;
import com.google.common.primitives.Booleans;
import com.google.errorprone.annotations.InlineMe;
import java.util.Comparator;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -265,6 +266,7 @@ public int result() {
* negated or reversed, undo the negation or reversal and use {@link #compareTrueFirst}.
* @since 19.0
*/
@InlineMe(replacement = "this.compareFalseFirst(left, right)")
@Deprecated
public final ComparisonChain compare(Boolean left, Boolean right) {
return compareFalseFirst(left, right);
Expand Down
Loading

0 comments on commit 4559277

Please sign in to comment.