2222import com .google .common .annotations .J2ktIncompatible ;
2323import com .google .common .base .Preconditions ;
2424import com .google .errorprone .annotations .CanIgnoreReturnValue ;
25+ import com .google .errorprone .annotations .InlineMe ;
2526import java .time .Duration ;
2627import java .util .ArrayDeque ;
2728import java .util .Collection ;
@@ -54,9 +55,18 @@ private Queues() {}
5455 /**
5556 * Creates an empty {@code ArrayBlockingQueue} with the given (fixed) capacity and nonfair access
5657 * policy.
58+ *
59+ * @deprecated Use the {@code ArrayBlockingQueue} {@linkplain
60+ * ArrayBlockingQueue#ArrayBlockingQueue(int) constructor} directly, taking advantage of <a
61+ * href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
62+ * syntax</a>.
5763 */
5864 @ J2ktIncompatible
5965 @ GwtIncompatible // ArrayBlockingQueue
66+ @ Deprecated
67+ @ InlineMe (
68+ replacement = "new ArrayBlockingQueue<>(capacity)" ,
69+ imports = "java.util.concurrent.ArrayBlockingQueue" )
6070 public static <E > ArrayBlockingQueue <E > newArrayBlockingQueue (int capacity ) {
6171 return new ArrayBlockingQueue <>(capacity );
6272 }
@@ -67,7 +77,13 @@ public static <E> ArrayBlockingQueue<E> newArrayBlockingQueue(int capacity) {
6777 * Creates an empty {@code ArrayDeque}.
6878 *
6979 * @since 12.0
80+ * @deprecated Use the {@code ArrayDeque} {@linkplain
81+ * ArrayDeque#ArrayDeque() constructor} directly, taking advantage of <a
82+ * href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
83+ * syntax</a>.
7084 */
85+ @ Deprecated
86+ @ InlineMe (replacement = "new ArrayDeque<>()" , imports = "java.util.ArrayDeque" )
7187 public static <E > ArrayDeque <E > newArrayDeque () {
7288 return new ArrayDeque <>();
7389 }
@@ -89,9 +105,20 @@ public static <E> ArrayDeque<E> newArrayDeque(Iterable<? extends E> elements) {
89105
90106 // ConcurrentLinkedQueue
91107
92- /** Creates an empty {@code ConcurrentLinkedQueue}. */
108+ /**
109+ * Creates an empty {@code ConcurrentLinkedQueue}.
110+ *
111+ * @deprecated Use the {@code ConcurrentLinkedQueue} {@linkplain
112+ * ConcurrentLinkedQueue#ConcurrentLinkedQueue() constructor} directly, taking advantage of <a
113+ * href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
114+ * syntax</a>.
115+ */
93116 @ J2ktIncompatible
94117 @ GwtIncompatible // ConcurrentLinkedQueue
118+ @ Deprecated
119+ @ InlineMe (
120+ replacement = "new ConcurrentLinkedQueue<>()" ,
121+ imports = "java.util.concurrent.ConcurrentLinkedQueue" )
95122 public static <E > ConcurrentLinkedQueue <E > newConcurrentLinkedQueue () {
96123 return new ConcurrentLinkedQueue <>();
97124 }
@@ -118,9 +145,17 @@ public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue(
118145 * Creates an empty {@code LinkedBlockingDeque} with a capacity of {@link Integer#MAX_VALUE}.
119146 *
120147 * @since 12.0
148+ * @deprecated Use the {@code LinkedBlockingDeque} {@linkplain
149+ * LinkedBlockingDeque#LinkedBlockingDeque() constructor} directly, taking advantage of <a
150+ * href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
151+ * syntax</a>.
121152 */
122153 @ J2ktIncompatible
123154 @ GwtIncompatible // LinkedBlockingDeque
155+ @ Deprecated
156+ @ InlineMe (
157+ replacement = "new LinkedBlockingDeque<>()" ,
158+ imports = "java.util.concurrent.LinkedBlockingDeque" )
124159 public static <E > LinkedBlockingDeque <E > newLinkedBlockingDeque () {
125160 return new LinkedBlockingDeque <>();
126161 }
@@ -130,9 +165,17 @@ public static <E> LinkedBlockingDeque<E> newLinkedBlockingDeque() {
130165 *
131166 * @throws IllegalArgumentException if {@code capacity} is less than 1
132167 * @since 12.0
168+ * @deprecated Use the {@code LinkedBlockingDeque} {@linkplain
169+ * LinkedBlockingDeque#LinkedBlockingDeque(int) constructor} directly, taking advantage of <a
170+ * href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
171+ * syntax</a>.
133172 */
134173 @ J2ktIncompatible
135174 @ GwtIncompatible // LinkedBlockingDeque
175+ @ Deprecated
176+ @ InlineMe (
177+ replacement = "new LinkedBlockingDeque<>(capacity)" ,
178+ imports = "java.util.concurrent.LinkedBlockingDeque" )
136179 public static <E > LinkedBlockingDeque <E > newLinkedBlockingDeque (int capacity ) {
137180 return new LinkedBlockingDeque <>(capacity );
138181 }
@@ -157,9 +200,20 @@ public static <E> LinkedBlockingDeque<E> newLinkedBlockingDeque(Iterable<? exten
157200
158201 // LinkedBlockingQueue
159202
160- /** Creates an empty {@code LinkedBlockingQueue} with a capacity of {@link Integer#MAX_VALUE}. */
203+ /**
204+ * Creates an empty {@code LinkedBlockingQueue} with a capacity of {@link Integer#MAX_VALUE}.
205+ *
206+ * @deprecated Use the {@code LinkedBlockingQueue} {@linkplain
207+ * LinkedBlockingQueue#LinkedBlockingQueue() constructor} directly, taking advantage of <a
208+ * href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
209+ * syntax</a>.
210+ */
161211 @ J2ktIncompatible
162212 @ GwtIncompatible // LinkedBlockingQueue
213+ @ Deprecated
214+ @ InlineMe (
215+ replacement = "new LinkedBlockingQueue<>()" ,
216+ imports = "java.util.concurrent.LinkedBlockingQueue" )
163217 public static <E > LinkedBlockingQueue <E > newLinkedBlockingQueue () {
164218 return new LinkedBlockingQueue <>();
165219 }
@@ -168,9 +222,17 @@ public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue() {
168222 * Creates an empty {@code LinkedBlockingQueue} with the given (fixed) capacity.
169223 *
170224 * @throws IllegalArgumentException if {@code capacity} is less than 1
225+ * @deprecated Use the {@code LinkedBlockingQueue} {@linkplain
226+ * LinkedBlockingQueue#LinkedBlockingQueue(int) constructor} directly, taking advantage of <a
227+ * href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
228+ * syntax</a>.
171229 */
172230 @ J2ktIncompatible
173231 @ GwtIncompatible // LinkedBlockingQueue
232+ @ Deprecated
233+ @ InlineMe (
234+ replacement = "new LinkedBlockingQueue<>(capacity)" ,
235+ imports = "java.util.concurrent.LinkedBlockingQueue" )
174236 public static <E > LinkedBlockingQueue <E > newLinkedBlockingQueue (int capacity ) {
175237 return new LinkedBlockingQueue <>(capacity );
176238 }
@@ -204,10 +266,18 @@ public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(Iterable<? exten
204266 *
205267 * @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
206268 * in 15.0)
269+ * @deprecated Use the {@code PriorityBlockingQueue} {@linkplain
270+ * PriorityBlockingQueue#PriorityBlockingQueue() constructor} directly, taking advantage of <a
271+ * href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
272+ * syntax</a>.
207273 */
208274 @ SuppressWarnings ("rawtypes" ) // https://github.com/google/guava/issues/989
209275 @ J2ktIncompatible
210276 @ GwtIncompatible // PriorityBlockingQueue
277+ @ Deprecated
278+ @ InlineMe (
279+ replacement = "new PriorityBlockingQueue<>()" ,
280+ imports = "java.util.concurrent.PriorityBlockingQueue" )
211281 public static <E extends Comparable > PriorityBlockingQueue <E > newPriorityBlockingQueue () {
212282 return new PriorityBlockingQueue <>();
213283 }
@@ -242,8 +312,14 @@ public static <E extends Comparable> PriorityBlockingQueue<E> newPriorityBlockin
242312 *
243313 * @since 11.0 (but the bound of {@code E} was changed from {@code Object} to {@code Comparable}
244314 * in 15.0)
315+ * @deprecated Use the {@code PriorityQueue} {@linkplain
316+ * PriorityQueue#PriorityQueue() constructor} directly, taking advantage of <a
317+ * href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
318+ * syntax</a>.
245319 */
246320 @ SuppressWarnings ("rawtypes" ) // https://github.com/google/guava/issues/989
321+ @ Deprecated
322+ @ InlineMe (replacement = "new PriorityQueue<>()" , imports = "java.util.PriorityQueue" )
247323 public static <E extends Comparable > PriorityQueue <E > newPriorityQueue () {
248324 return new PriorityQueue <>();
249325 }
@@ -270,9 +346,20 @@ public static <E extends Comparable> PriorityQueue<E> newPriorityQueue(
270346
271347 // SynchronousQueue
272348
273- /** Creates an empty {@code SynchronousQueue} with nonfair access policy. */
349+ /**
350+ * Creates an empty {@code SynchronousQueue} with nonfair access policy.
351+ *
352+ * @deprecated Use the {@code SynchronousQueue} {@linkplain
353+ * SynchronousQueue#SynchronousQueue() constructor} directly, taking advantage of <a
354+ * href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
355+ * syntax</a>.
356+ */
274357 @ J2ktIncompatible
275358 @ GwtIncompatible // SynchronousQueue
359+ @ Deprecated
360+ @ InlineMe (
361+ replacement = "new SynchronousQueue<>()" ,
362+ imports = "java.util.concurrent.SynchronousQueue" )
276363 public static <E > SynchronousQueue <E > newSynchronousQueue () {
277364 return new SynchronousQueue <>();
278365 }
0 commit comments