diff --git a/android/guava/src/com/google/common/collect/Lists.java b/android/guava/src/com/google/common/collect/Lists.java
index 304a5f57a32f..d0dae0d51a96 100644
--- a/android/guava/src/com/google/common/collect/Lists.java
+++ b/android/guava/src/com/google/common/collect/Lists.java
@@ -77,13 +77,14 @@ private Lists() {}
*
*
Note: if mutability is not required, use {@link ImmutableList#of()} instead.
*
- *
Note: 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 "diamond"
* syntax.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
+ @Deprecated
+ @InlineMe(replacement = "new ArrayList<>()", imports = "java.util.ArrayList")
public static ArrayList newArrayList() {
return new ArrayList<>();
}
@@ -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.
*
- * Note: 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 "diamond"
* syntax.
@@ -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 LinkedList newLinkedList() {
return new LinkedList<>();
}
@@ -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 "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // CopyOnWriteArrayList
@InlineMe(
replacement = "new CopyOnWriteArrayList<>()",
imports = {"java.util.concurrent.CopyOnWriteArrayList"})
+ @Deprecated
public static CopyOnWriteArrayList newCopyOnWriteArrayList() {
return new CopyOnWriteArrayList<>();
}
diff --git a/android/guava/src/com/google/common/collect/Maps.java b/android/guava/src/com/google/common/collect/Maps.java
index e7bc98145f66..b8b5c1b864c8 100644
--- a/android/guava/src/com/google/common/collect/Maps.java
+++ b/android/guava/src/com/google/common/collect/Maps.java
@@ -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;
@@ -216,14 +217,15 @@ public static , V> ImmutableMap immutableEnumMap(
*
* Note: if {@code K} is an {@code enum} type, use {@link #newEnumMap} instead.
*
- *
Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code HashMap} constructor directly, taking advantage of "diamond"
- * syntax.
- *
* @return a new, empty {@code HashMap}
+ * @deprecated Use the {@code HashMap} {@linkplain
+ * HashMap#HashMap() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
+ @Deprecated
+ @InlineMe(replacement = "new HashMap<>()", imports = "java.util.HashMap")
public static
HashMap newHashMap() {
return new HashMap<>();
@@ -299,14 +301,15 @@ static int capacity(int expectedSize) {
*
* Note: if mutability is not required, use {@link ImmutableMap#of()} instead.
*
- *
Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code LinkedHashMap} constructor directly, taking advantage of "diamond"
- * syntax.
- *
* @return a new, empty {@code LinkedHashMap}
+ * @deprecated Use the {@code LinkedHashMap} {@linkplain
+ * LinkedHashMap#LinkedHashMap() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
+ @Deprecated
+ @InlineMe(replacement = "new LinkedHashMap<>()", imports = "java.util.LinkedHashMap")
public static
LinkedHashMap newLinkedHashMap() {
return new LinkedHashMap<>();
@@ -353,13 +356,16 @@ LinkedHashMap newLinkedHashMapWithExpectedSize(int expectedSize) {
/**
* Creates a new empty {@link ConcurrentHashMap} instance.
*
- * Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code ConcurrentHashMap} constructor directly, taking advantage of "diamond"
- * syntax.
- *
* @since 3.0
+ * @deprecated Use the {@code ConcurrentHashMap} {@linkplain
+ * ConcurrentHashMap#ConcurrentHashMap() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
+ @Deprecated
+ @InlineMe(
+ replacement = "new ConcurrentHashMap<>()",
+ imports = "java.util.concurrent.ConcurrentHashMap")
public static ConcurrentMap newConcurrentMap() {
return new ConcurrentHashMap<>();
}
@@ -438,7 +444,16 @@ TreeMap newTreeMap(@Nullable Comparator 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 "diamond"
+ * syntax.
*/
+ @Deprecated
+ @InlineMe(
+ replacement = "new EnumMap<>(checkNotNull(type))",
+ imports = "java.util.EnumMap",
+ staticImports = "com.google.common.base.Preconditions.checkNotNull")
public static , V extends @Nullable Object> EnumMap newEnumMap(
Class type) {
return new EnumMap<>(checkNotNull(type));
@@ -465,13 +480,14 @@ TreeMap newTreeMap(@Nullable Comparator comparator) {
/**
* Creates an {@code IdentityHashMap} instance.
*
- * Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code IdentityHashMap} constructor directly, taking advantage of "diamond"
- * syntax.
- *
* @return a new, empty {@code IdentityHashMap}
+ * @deprecated Use the {@code IdentityHashMap} {@linkplain
+ * IdentityHashMap#IdentityHashMap() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
+ @Deprecated
+ @InlineMe(replacement = "new IdentityHashMap<>()", imports = "java.util.IdentityHashMap")
public static
IdentityHashMap newIdentityHashMap() {
return new IdentityHashMap<>();
diff --git a/android/guava/src/com/google/common/collect/Queues.java b/android/guava/src/com/google/common/collect/Queues.java
index 374c09784aed..8e68a4a2071b 100644
--- a/android/guava/src/com/google/common/collect/Queues.java
+++ b/android/guava/src/com/google/common/collect/Queues.java
@@ -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;
@@ -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 "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // ArrayBlockingQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new ArrayBlockingQueue<>(capacity)",
+ imports = "java.util.concurrent.ArrayBlockingQueue")
public static ArrayBlockingQueue newArrayBlockingQueue(int capacity) {
return new ArrayBlockingQueue<>(capacity);
}
@@ -67,7 +77,13 @@ public static ArrayBlockingQueue newArrayBlockingQueue(int capacity) {
* Creates an empty {@code ArrayDeque}.
*
* @since 12.0
+ * @deprecated Use the {@code ArrayDeque} {@linkplain
+ * ArrayDeque#ArrayDeque() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
+ @Deprecated
+ @InlineMe(replacement = "new ArrayDeque<>()", imports = "java.util.ArrayDeque")
public static ArrayDeque newArrayDeque() {
return new ArrayDeque<>();
}
@@ -89,9 +105,20 @@ public static ArrayDeque 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 "diamond"
+ * syntax.
+ */
@J2ktIncompatible
@GwtIncompatible // ConcurrentLinkedQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new ConcurrentLinkedQueue<>()",
+ imports = "java.util.concurrent.ConcurrentLinkedQueue")
public static ConcurrentLinkedQueue newConcurrentLinkedQueue() {
return new ConcurrentLinkedQueue<>();
}
@@ -118,9 +145,17 @@ public static ConcurrentLinkedQueue 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 "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingDeque
+ @Deprecated
+ @InlineMe(
+ replacement = "new LinkedBlockingDeque<>()",
+ imports = "java.util.concurrent.LinkedBlockingDeque")
public static LinkedBlockingDeque newLinkedBlockingDeque() {
return new LinkedBlockingDeque<>();
}
@@ -130,9 +165,17 @@ public static LinkedBlockingDeque 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 "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingDeque
+ @Deprecated
+ @InlineMe(
+ replacement = "new LinkedBlockingDeque<>(capacity)",
+ imports = "java.util.concurrent.LinkedBlockingDeque")
public static LinkedBlockingDeque newLinkedBlockingDeque(int capacity) {
return new LinkedBlockingDeque<>(capacity);
}
@@ -157,9 +200,20 @@ public static LinkedBlockingDeque 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 "diamond"
+ * syntax.
+ */
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new LinkedBlockingQueue<>()",
+ imports = "java.util.concurrent.LinkedBlockingQueue")
public static LinkedBlockingQueue newLinkedBlockingQueue() {
return new LinkedBlockingQueue<>();
}
@@ -168,9 +222,17 @@ public static LinkedBlockingQueue 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 "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new LinkedBlockingQueue<>(capacity)",
+ imports = "java.util.concurrent.LinkedBlockingQueue")
public static LinkedBlockingQueue newLinkedBlockingQueue(int capacity) {
return new LinkedBlockingQueue<>(capacity);
}
@@ -204,10 +266,18 @@ public static LinkedBlockingQueue 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 "diamond"
+ * syntax.
*/
@SuppressWarnings("rawtypes") // https://github.com/google/guava/issues/989
@J2ktIncompatible
@GwtIncompatible // PriorityBlockingQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new PriorityBlockingQueue<>()",
+ imports = "java.util.concurrent.PriorityBlockingQueue")
public static PriorityBlockingQueue newPriorityBlockingQueue() {
return new PriorityBlockingQueue<>();
}
@@ -242,8 +312,14 @@ public static PriorityBlockingQueue 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 "diamond"
+ * syntax.
*/
@SuppressWarnings("rawtypes") // https://github.com/google/guava/issues/989
+ @Deprecated
+ @InlineMe(replacement = "new PriorityQueue<>()", imports = "java.util.PriorityQueue")
public static PriorityQueue newPriorityQueue() {
return new PriorityQueue<>();
}
@@ -270,9 +346,20 @@ public static PriorityQueue 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 "diamond"
+ * syntax.
+ */
@J2ktIncompatible
@GwtIncompatible // SynchronousQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new SynchronousQueue<>()",
+ imports = "java.util.concurrent.SynchronousQueue")
public static SynchronousQueue newSynchronousQueue() {
return new SynchronousQueue<>();
}
diff --git a/android/guava/src/com/google/common/collect/Sets.java b/android/guava/src/com/google/common/collect/Sets.java
index 739f3358b976..ffde32a107be 100644
--- a/android/guava/src/com/google/common/collect/Sets.java
+++ b/android/guava/src/com/google/common/collect/Sets.java
@@ -184,12 +184,14 @@ public static > EnumSet newEnumSet(
* using a {@code LinkedHashSet} instead, at the cost of increased memory footprint, to get
* deterministic iteration behavior.
*
- * Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code HashSet} constructor directly, taking advantage of "diamond"
- * syntax.
+ * @deprecated Use the {@code HashSet} {@linkplain
+ * HashSet#HashSet() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
+ @Deprecated
+ @InlineMe(replacement = "new HashSet<>()", imports = "java.util.HashSet")
public static HashSet newHashSet() {
return new HashSet<>();
}
@@ -316,14 +318,15 @@ public static Set newConcurrentHashSet(Iterable extends E> elements) {
*
* Note: if mutability is not required, use {@link ImmutableSet#of()} instead.
*
- *
Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code LinkedHashSet} constructor directly, taking advantage of "diamond"
- * syntax.
- *
* @return a new, empty {@code LinkedHashSet}
+ * @deprecated Use the {@code LinkedHashSet} {@linkplain
+ * LinkedHashSet#LinkedHashSet() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
+ @Deprecated
+ @InlineMe(replacement = "new LinkedHashSet<>()", imports = "java.util.LinkedHashSet")
public static LinkedHashSet newLinkedHashSet() {
return new LinkedHashSet<>();
}
@@ -472,9 +475,17 @@ public static TreeSet newTreeSet(Iterable extends E>
*
* @return a new, empty {@code CopyOnWriteArraySet}
* @since 12.0
+ * @deprecated Use the {@code CopyOnWriteArraySet} {@linkplain
+ * CopyOnWriteArraySet#CopyOnWriteArraySet() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // CopyOnWriteArraySet
+ @Deprecated
+ @InlineMe(
+ replacement = "new CopyOnWriteArraySet<>()",
+ imports = "java.util.concurrent.CopyOnWriteArraySet")
public static CopyOnWriteArraySet newCopyOnWriteArraySet() {
return new CopyOnWriteArraySet<>();
}
diff --git a/guava/src/com/google/common/collect/Lists.java b/guava/src/com/google/common/collect/Lists.java
index ae79f5e659c1..93768a18ad32 100644
--- a/guava/src/com/google/common/collect/Lists.java
+++ b/guava/src/com/google/common/collect/Lists.java
@@ -78,13 +78,14 @@ private Lists() {}
*
* Note: if mutability is not required, use {@link ImmutableList#of()} instead.
*
- *
Note: 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 "diamond"
* syntax.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
+ @Deprecated
+ @InlineMe(replacement = "new ArrayList<>()", imports = "java.util.ArrayList")
public static ArrayList newArrayList() {
return new ArrayList<>();
}
@@ -214,8 +215,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.
*
- * Note: 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 "diamond"
* syntax.
@@ -224,6 +224,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 LinkedList newLinkedList() {
return new LinkedList<>();
}
@@ -261,12 +263,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 "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // CopyOnWriteArrayList
@InlineMe(
replacement = "new CopyOnWriteArrayList<>()",
imports = {"java.util.concurrent.CopyOnWriteArrayList"})
+ @Deprecated
public static CopyOnWriteArrayList newCopyOnWriteArrayList() {
return new CopyOnWriteArrayList<>();
}
diff --git a/guava/src/com/google/common/collect/Maps.java b/guava/src/com/google/common/collect/Maps.java
index bb8173481186..c587ac4febbb 100644
--- a/guava/src/com/google/common/collect/Maps.java
+++ b/guava/src/com/google/common/collect/Maps.java
@@ -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;
@@ -219,14 +220,15 @@ public static , V> ImmutableMap immutableEnumMap(
*
* Note: if {@code K} is an {@code enum} type, use {@link #newEnumMap} instead.
*
- *
Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code HashMap} constructor directly, taking advantage of "diamond"
- * syntax.
- *
* @return a new, empty {@code HashMap}
+ * @deprecated Use the {@code HashMap} {@linkplain
+ * HashMap#HashMap() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
+ @Deprecated
+ @InlineMe(replacement = "new HashMap<>()", imports = "java.util.HashMap")
public static
HashMap newHashMap() {
return new HashMap<>();
@@ -302,14 +304,15 @@ static int capacity(int expectedSize) {
*
* Note: if mutability is not required, use {@link ImmutableMap#of()} instead.
*
- *
Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code LinkedHashMap} constructor directly, taking advantage of "diamond"
- * syntax.
- *
* @return a new, empty {@code LinkedHashMap}
+ * @deprecated Use the {@code LinkedHashMap} {@linkplain
+ * LinkedHashMap#LinkedHashMap() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
+ @Deprecated
+ @InlineMe(replacement = "new LinkedHashMap<>()", imports = "java.util.LinkedHashMap")
public static
LinkedHashMap newLinkedHashMap() {
return new LinkedHashMap<>();
@@ -356,13 +359,16 @@ LinkedHashMap newLinkedHashMapWithExpectedSize(int expectedSize) {
/**
* Creates a new empty {@link ConcurrentHashMap} instance.
*
- * Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code ConcurrentHashMap} constructor directly, taking advantage of "diamond"
- * syntax.
- *
* @since 3.0
+ * @deprecated Use the {@code ConcurrentHashMap} {@linkplain
+ * ConcurrentHashMap#ConcurrentHashMap() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
+ @Deprecated
+ @InlineMe(
+ replacement = "new ConcurrentHashMap<>()",
+ imports = "java.util.concurrent.ConcurrentHashMap")
public static ConcurrentMap newConcurrentMap() {
return new ConcurrentHashMap<>();
}
@@ -441,7 +447,16 @@ TreeMap newTreeMap(@Nullable Comparator 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 "diamond"
+ * syntax.
*/
+ @Deprecated
+ @InlineMe(
+ replacement = "new EnumMap<>(checkNotNull(type))",
+ imports = "java.util.EnumMap",
+ staticImports = "com.google.common.base.Preconditions.checkNotNull")
public static , V extends @Nullable Object> EnumMap newEnumMap(
Class type) {
return new EnumMap<>(checkNotNull(type));
@@ -468,13 +483,14 @@ TreeMap newTreeMap(@Nullable Comparator comparator) {
/**
* Creates an {@code IdentityHashMap} instance.
*
- * Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code IdentityHashMap} constructor directly, taking advantage of "diamond"
- * syntax.
- *
* @return a new, empty {@code IdentityHashMap}
+ * @deprecated Use the {@code IdentityHashMap} {@linkplain
+ * IdentityHashMap#IdentityHashMap() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
+ @Deprecated
+ @InlineMe(replacement = "new IdentityHashMap<>()", imports = "java.util.IdentityHashMap")
public static
IdentityHashMap newIdentityHashMap() {
return new IdentityHashMap<>();
diff --git a/guava/src/com/google/common/collect/Queues.java b/guava/src/com/google/common/collect/Queues.java
index 41feea89901b..e4fcb23aeafa 100644
--- a/guava/src/com/google/common/collect/Queues.java
+++ b/guava/src/com/google/common/collect/Queues.java
@@ -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;
@@ -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 "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // ArrayBlockingQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new ArrayBlockingQueue<>(capacity)",
+ imports = "java.util.concurrent.ArrayBlockingQueue")
public static ArrayBlockingQueue newArrayBlockingQueue(int capacity) {
return new ArrayBlockingQueue<>(capacity);
}
@@ -67,7 +77,13 @@ public static ArrayBlockingQueue newArrayBlockingQueue(int capacity) {
* Creates an empty {@code ArrayDeque}.
*
* @since 12.0
+ * @deprecated Use the {@code ArrayDeque} {@linkplain
+ * ArrayDeque#ArrayDeque() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
+ @Deprecated
+ @InlineMe(replacement = "new ArrayDeque<>()", imports = "java.util.ArrayDeque")
public static ArrayDeque newArrayDeque() {
return new ArrayDeque<>();
}
@@ -89,9 +105,20 @@ public static ArrayDeque 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 "diamond"
+ * syntax.
+ */
@J2ktIncompatible
@GwtIncompatible // ConcurrentLinkedQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new ConcurrentLinkedQueue<>()",
+ imports = "java.util.concurrent.ConcurrentLinkedQueue")
public static ConcurrentLinkedQueue newConcurrentLinkedQueue() {
return new ConcurrentLinkedQueue<>();
}
@@ -118,9 +145,17 @@ public static ConcurrentLinkedQueue 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 "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingDeque
+ @Deprecated
+ @InlineMe(
+ replacement = "new LinkedBlockingDeque<>()",
+ imports = "java.util.concurrent.LinkedBlockingDeque")
public static LinkedBlockingDeque newLinkedBlockingDeque() {
return new LinkedBlockingDeque<>();
}
@@ -130,9 +165,17 @@ public static LinkedBlockingDeque 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 "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingDeque
+ @Deprecated
+ @InlineMe(
+ replacement = "new LinkedBlockingDeque<>(capacity)",
+ imports = "java.util.concurrent.LinkedBlockingDeque")
public static LinkedBlockingDeque newLinkedBlockingDeque(int capacity) {
return new LinkedBlockingDeque<>(capacity);
}
@@ -157,9 +200,20 @@ public static LinkedBlockingDeque 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 "diamond"
+ * syntax.
+ */
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new LinkedBlockingQueue<>()",
+ imports = "java.util.concurrent.LinkedBlockingQueue")
public static LinkedBlockingQueue newLinkedBlockingQueue() {
return new LinkedBlockingQueue<>();
}
@@ -168,9 +222,17 @@ public static LinkedBlockingQueue 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 "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // LinkedBlockingQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new LinkedBlockingQueue<>(capacity)",
+ imports = "java.util.concurrent.LinkedBlockingQueue")
public static LinkedBlockingQueue newLinkedBlockingQueue(int capacity) {
return new LinkedBlockingQueue<>(capacity);
}
@@ -204,10 +266,18 @@ public static LinkedBlockingQueue 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 "diamond"
+ * syntax.
*/
@SuppressWarnings("rawtypes") // https://github.com/google/guava/issues/989
@J2ktIncompatible
@GwtIncompatible // PriorityBlockingQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new PriorityBlockingQueue<>()",
+ imports = "java.util.concurrent.PriorityBlockingQueue")
public static PriorityBlockingQueue newPriorityBlockingQueue() {
return new PriorityBlockingQueue<>();
}
@@ -242,8 +312,14 @@ public static PriorityBlockingQueue 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 "diamond"
+ * syntax.
*/
@SuppressWarnings("rawtypes") // https://github.com/google/guava/issues/989
+ @Deprecated
+ @InlineMe(replacement = "new PriorityQueue<>()", imports = "java.util.PriorityQueue")
public static PriorityQueue newPriorityQueue() {
return new PriorityQueue<>();
}
@@ -270,9 +346,20 @@ public static PriorityQueue 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 "diamond"
+ * syntax.
+ */
@J2ktIncompatible
@GwtIncompatible // SynchronousQueue
+ @Deprecated
+ @InlineMe(
+ replacement = "new SynchronousQueue<>()",
+ imports = "java.util.concurrent.SynchronousQueue")
public static SynchronousQueue newSynchronousQueue() {
return new SynchronousQueue<>();
}
diff --git a/guava/src/com/google/common/collect/Sets.java b/guava/src/com/google/common/collect/Sets.java
index 7c7092f08fec..79dd94910d4a 100644
--- a/guava/src/com/google/common/collect/Sets.java
+++ b/guava/src/com/google/common/collect/Sets.java
@@ -185,12 +185,14 @@ public static > EnumSet newEnumSet(
* using a {@code LinkedHashSet} instead, at the cost of increased memory footprint, to get
* deterministic iteration behavior.
*
- * Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code HashSet} constructor directly, taking advantage of "diamond"
- * syntax.
+ * @deprecated Use the {@code HashSet} {@linkplain
+ * HashSet#HashSet() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
+ @Deprecated
+ @InlineMe(replacement = "new HashSet<>()", imports = "java.util.HashSet")
public static HashSet newHashSet() {
return new HashSet<>();
}
@@ -317,14 +319,15 @@ public static Set newConcurrentHashSet(Iterable extends E> elements) {
*
* Note: if mutability is not required, use {@link ImmutableSet#of()} instead.
*
- *
Note: this method is now unnecessary and should be treated as deprecated. Instead,
- * use the {@code LinkedHashSet} constructor directly, taking advantage of "diamond"
- * syntax.
- *
* @return a new, empty {@code LinkedHashSet}
+ * @deprecated Use the {@code LinkedHashSet} {@linkplain
+ * LinkedHashSet#LinkedHashSet() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
+ @Deprecated
+ @InlineMe(replacement = "new LinkedHashSet<>()", imports = "java.util.LinkedHashSet")
public static LinkedHashSet newLinkedHashSet() {
return new LinkedHashSet<>();
}
@@ -473,9 +476,17 @@ public static TreeSet newTreeSet(Iterable extends E>
*
* @return a new, empty {@code CopyOnWriteArraySet}
* @since 12.0
+ * @deprecated Use the {@code CopyOnWriteArraySet} {@linkplain
+ * CopyOnWriteArraySet#CopyOnWriteArraySet() constructor} directly, taking advantage of "diamond"
+ * syntax.
*/
@J2ktIncompatible
@GwtIncompatible // CopyOnWriteArraySet
+ @Deprecated
+ @InlineMe(
+ replacement = "new CopyOnWriteArraySet<>()",
+ imports = "java.util.concurrent.CopyOnWriteArraySet")
public static CopyOnWriteArraySet newCopyOnWriteArraySet() {
return new CopyOnWriteArraySet<>();
}