Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions android/guava/src/com/google/common/collect/Lists.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ private Lists() {}
*
* <p><b>Note:</b> if mutability is not required, use {@link ImmutableList#of()} instead.
*
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated. Instead,
* use the {@code ArrayList} {@linkplain ArrayList#ArrayList() constructor} directly, taking
* @deprecated Use the {@code ArrayList} {@linkplain ArrayList#ArrayList() constructor} directly, taking
* advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
@Deprecated
@InlineMe(replacement = "new ArrayList<>()", imports = "java.util.ArrayList")
public static <E extends @Nullable Object> ArrayList<E> newArrayList() {
return new ArrayList<>();
}
Expand Down Expand Up @@ -213,8 +214,7 @@ static int computeArrayListCapacity(int arraySize) {
* outperform {@code LinkedList} except in certain rare and specific situations. Unless you have
* spent a lot of time benchmarking your specific needs, use one of those instead.
*
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated. Instead,
* use the {@code LinkedList} {@linkplain LinkedList#LinkedList() constructor} directly, taking
* @deprecated Use the {@code LinkedList} {@linkplain LinkedList#LinkedList() constructor} directly, taking
* advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
Expand All @@ -223,6 +223,8 @@ static int computeArrayListCapacity(int arraySize) {
"NonApiType", // acts as a direct substitute for a constructor call
"JdkObsolete", // We recommend against this method but need to keep it for compatibility.
})
@Deprecated
@InlineMe(replacement = "new LinkedList<>()", imports = "java.util.LinkedList")
public static <E extends @Nullable Object> LinkedList<E> newLinkedList() {
return new LinkedList<>();
}
Expand Down Expand Up @@ -260,12 +262,17 @@ static int computeArrayListCapacity(int arraySize) {
*
* @return a new, empty {@code CopyOnWriteArrayList}
* @since 12.0
* @deprecated Use the {@code CopyOnWriteArrayList} {@linkplain
* CopyOnWriteArrayList#CopyOnWriteArrayList() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@J2ktIncompatible
@GwtIncompatible // CopyOnWriteArrayList
@InlineMe(
replacement = "new CopyOnWriteArrayList<>()",
imports = {"java.util.concurrent.CopyOnWriteArrayList"})
@Deprecated
public static <E extends @Nullable Object> CopyOnWriteArrayList<E> newCopyOnWriteArrayList() {
return new CopyOnWriteArrayList<>();
}
Expand Down
56 changes: 36 additions & 20 deletions android/guava/src/com/google/common/collect/Maps.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import com.google.common.collect.MapDifference.ValueDifference;
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 com.google.j2objc.annotations.RetainedWith;
import com.google.j2objc.annotations.Weak;
Expand Down Expand Up @@ -216,14 +217,15 @@ public static <K extends Enum<K>, V> ImmutableMap<K, V> immutableEnumMap(
*
* <p><b>Note:</b> if {@code K} is an {@code enum} type, use {@link #newEnumMap} instead.
*
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated. Instead,
* use the {@code HashMap} constructor directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*
* @return a new, empty {@code HashMap}
* @deprecated Use the {@code HashMap} {@linkplain
* HashMap#HashMap() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
@Deprecated
@InlineMe(replacement = "new HashMap<>()", imports = "java.util.HashMap")
public static <K extends @Nullable Object, V extends @Nullable Object>
HashMap<K, V> newHashMap() {
return new HashMap<>();
Expand Down Expand Up @@ -299,14 +301,15 @@ static int capacity(int expectedSize) {
*
* <p><b>Note:</b> if mutability is not required, use {@link ImmutableMap#of()} instead.
*
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated. Instead,
* use the {@code LinkedHashMap} constructor directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*
* @return a new, empty {@code LinkedHashMap}
* @deprecated Use the {@code LinkedHashMap} {@linkplain
* LinkedHashMap#LinkedHashMap() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
@Deprecated
@InlineMe(replacement = "new LinkedHashMap<>()", imports = "java.util.LinkedHashMap")
public static <K extends @Nullable Object, V extends @Nullable Object>
LinkedHashMap<K, V> newLinkedHashMap() {
return new LinkedHashMap<>();
Expand Down Expand Up @@ -353,13 +356,16 @@ LinkedHashMap<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) {
/**
* Creates a new empty {@link ConcurrentHashMap} instance.
*
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated. Instead,
* use the {@code ConcurrentHashMap} constructor directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*
* @since 3.0
* @deprecated Use the {@code ConcurrentHashMap} {@linkplain
* ConcurrentHashMap#ConcurrentHashMap() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@Deprecated
@InlineMe(
replacement = "new ConcurrentHashMap<>()",
imports = "java.util.concurrent.ConcurrentHashMap")
public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
return new ConcurrentHashMap<>();
}
Expand Down Expand Up @@ -438,7 +444,16 @@ TreeMap<K, V> newTreeMap(@Nullable Comparator<C> comparator) {
*
* @param type the key type for this map
* @return a new, empty {@code EnumMap}
* @deprecated Use the {@code EnumMap} {@linkplain EnumMap#EnumMap(Class) constructor} directly,
* taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@Deprecated
@InlineMe(
replacement = "new EnumMap<>(checkNotNull(type))",
imports = "java.util.EnumMap",
staticImports = "com.google.common.base.Preconditions.checkNotNull")
public static <K extends Enum<K>, V extends @Nullable Object> EnumMap<K, V> newEnumMap(
Class<K> type) {
return new EnumMap<>(checkNotNull(type));
Expand All @@ -465,13 +480,14 @@ TreeMap<K, V> newTreeMap(@Nullable Comparator<C> comparator) {
/**
* Creates an {@code IdentityHashMap} instance.
*
* <p><b>Note:</b> this method is now unnecessary and should be treated as deprecated. Instead,
* use the {@code IdentityHashMap} constructor directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*
* @return a new, empty {@code IdentityHashMap}
* @deprecated Use the {@code IdentityHashMap} {@linkplain
* IdentityHashMap#IdentityHashMap() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@Deprecated
@InlineMe(replacement = "new IdentityHashMap<>()", imports = "java.util.IdentityHashMap")
public static <K extends @Nullable Object, V extends @Nullable Object>
IdentityHashMap<K, V> newIdentityHashMap() {
return new IdentityHashMap<>();
Expand Down
93 changes: 90 additions & 3 deletions android/guava/src/com/google/common/collect/Queues.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.InlineMe;
import java.time.Duration;
import java.util.ArrayDeque;
import java.util.Collection;
Expand Down Expand Up @@ -54,9 +55,18 @@ private Queues() {}
/**
* Creates an empty {@code ArrayBlockingQueue} with the given (fixed) capacity and nonfair access
* policy.
*
* @deprecated Use the {@code ArrayBlockingQueue} {@linkplain
* ArrayBlockingQueue#ArrayBlockingQueue(int) constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@J2ktIncompatible
@GwtIncompatible // ArrayBlockingQueue
@Deprecated
@InlineMe(
replacement = "new ArrayBlockingQueue<>(capacity)",
imports = "java.util.concurrent.ArrayBlockingQueue")
public static <E> ArrayBlockingQueue<E> newArrayBlockingQueue(int capacity) {
return new ArrayBlockingQueue<>(capacity);
}
Expand All @@ -67,7 +77,13 @@ public static <E> ArrayBlockingQueue<E> newArrayBlockingQueue(int capacity) {
* Creates an empty {@code ArrayDeque}.
*
* @since 12.0
* @deprecated Use the {@code ArrayDeque} {@linkplain
* ArrayDeque#ArrayDeque() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@Deprecated
@InlineMe(replacement = "new ArrayDeque<>()", imports = "java.util.ArrayDeque")
public static <E> ArrayDeque<E> newArrayDeque() {
return new ArrayDeque<>();
}
Expand All @@ -89,9 +105,20 @@ public static <E> ArrayDeque<E> newArrayDeque(Iterable<? extends E> elements) {

// ConcurrentLinkedQueue

/** Creates an empty {@code ConcurrentLinkedQueue}. */
/**
* Creates an empty {@code ConcurrentLinkedQueue}.
*
* @deprecated Use the {@code ConcurrentLinkedQueue} {@linkplain
* ConcurrentLinkedQueue#ConcurrentLinkedQueue() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@J2ktIncompatible
@GwtIncompatible // ConcurrentLinkedQueue
@Deprecated
@InlineMe(
replacement = "new ConcurrentLinkedQueue<>()",
imports = "java.util.concurrent.ConcurrentLinkedQueue")
public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue() {
return new ConcurrentLinkedQueue<>();
}
Expand All @@ -118,9 +145,17 @@ public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue(
* Creates an empty {@code LinkedBlockingDeque} with a capacity of {@link Integer#MAX_VALUE}.
*
* @since 12.0
* @deprecated Use the {@code LinkedBlockingDeque} {@linkplain
* LinkedBlockingDeque#LinkedBlockingDeque() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingDeque
@Deprecated
@InlineMe(
replacement = "new LinkedBlockingDeque<>()",
imports = "java.util.concurrent.LinkedBlockingDeque")
public static <E> LinkedBlockingDeque<E> newLinkedBlockingDeque() {
return new LinkedBlockingDeque<>();
}
Expand All @@ -130,9 +165,17 @@ public static <E> LinkedBlockingDeque<E> newLinkedBlockingDeque() {
*
* @throws IllegalArgumentException if {@code capacity} is less than 1
* @since 12.0
* @deprecated Use the {@code LinkedBlockingDeque} {@linkplain
* LinkedBlockingDeque#LinkedBlockingDeque(int) constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingDeque
@Deprecated
@InlineMe(
replacement = "new LinkedBlockingDeque<>(capacity)",
imports = "java.util.concurrent.LinkedBlockingDeque")
public static <E> LinkedBlockingDeque<E> newLinkedBlockingDeque(int capacity) {
return new LinkedBlockingDeque<>(capacity);
}
Expand All @@ -157,9 +200,20 @@ public static <E> LinkedBlockingDeque<E> newLinkedBlockingDeque(Iterable<? exten

// LinkedBlockingQueue

/** Creates an empty {@code LinkedBlockingQueue} with a capacity of {@link Integer#MAX_VALUE}. */
/**
* Creates an empty {@code LinkedBlockingQueue} with a capacity of {@link Integer#MAX_VALUE}.
*
* @deprecated Use the {@code LinkedBlockingQueue} {@linkplain
* LinkedBlockingQueue#LinkedBlockingQueue() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingQueue
@Deprecated
@InlineMe(
replacement = "new LinkedBlockingQueue<>()",
imports = "java.util.concurrent.LinkedBlockingQueue")
public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue() {
return new LinkedBlockingQueue<>();
}
Expand All @@ -168,9 +222,17 @@ public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue() {
* Creates an empty {@code LinkedBlockingQueue} with the given (fixed) capacity.
*
* @throws IllegalArgumentException if {@code capacity} is less than 1
* @deprecated Use the {@code LinkedBlockingQueue} {@linkplain
* LinkedBlockingQueue#LinkedBlockingQueue(int) constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingQueue
@Deprecated
@InlineMe(
replacement = "new LinkedBlockingQueue<>(capacity)",
imports = "java.util.concurrent.LinkedBlockingQueue")
public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(int capacity) {
return new LinkedBlockingQueue<>(capacity);
}
Expand Down Expand Up @@ -204,10 +266,18 @@ public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(Iterable<? exten
*
* @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
* in 15.0)
* @deprecated Use the {@code PriorityBlockingQueue} {@linkplain
* PriorityBlockingQueue#PriorityBlockingQueue() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@SuppressWarnings("rawtypes") // https://github.com/google/guava/issues/989
@J2ktIncompatible
@GwtIncompatible // PriorityBlockingQueue
@Deprecated
@InlineMe(
replacement = "new PriorityBlockingQueue<>()",
imports = "java.util.concurrent.PriorityBlockingQueue")
public static <E extends Comparable> PriorityBlockingQueue<E> newPriorityBlockingQueue() {
return new PriorityBlockingQueue<>();
}
Expand Down Expand Up @@ -242,8 +312,14 @@ public static <E extends Comparable> PriorityBlockingQueue<E> newPriorityBlockin
*
* @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
* in 15.0)
* @deprecated Use the {@code PriorityQueue} {@linkplain
* PriorityQueue#PriorityQueue() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@SuppressWarnings("rawtypes") // https://github.com/google/guava/issues/989
@Deprecated
@InlineMe(replacement = "new PriorityQueue<>()", imports = "java.util.PriorityQueue")
public static <E extends Comparable> PriorityQueue<E> newPriorityQueue() {
return new PriorityQueue<>();
}
Expand All @@ -270,9 +346,20 @@ public static <E extends Comparable> PriorityQueue<E> newPriorityQueue(

// SynchronousQueue

/** Creates an empty {@code SynchronousQueue} with nonfair access policy. */
/**
* Creates an empty {@code SynchronousQueue} with nonfair access policy.
*
* @deprecated Use the {@code SynchronousQueue} {@linkplain
* SynchronousQueue#SynchronousQueue() constructor} directly, taking advantage of <a
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
* syntax</a>.
*/
@J2ktIncompatible
@GwtIncompatible // SynchronousQueue
@Deprecated
@InlineMe(
replacement = "new SynchronousQueue<>()",
imports = "java.util.concurrent.SynchronousQueue")
public static <E> SynchronousQueue<E> newSynchronousQueue() {
return new SynchronousQueue<>();
}
Expand Down
Loading
Loading