Package org.kiwiproject.collect
Class KiwiEvictingQueues
- java.lang.Object
-
- org.kiwiproject.collect.KiwiEvictingQueues
-
public class KiwiEvictingQueues extends Object
Utility methods for working with GuavaEvictingQueue
instances.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_RECENT_ITEMS
The default maximum number ofEvictingQueue
items.
-
Constructor Summary
Constructors Constructor Description KiwiEvictingQueues()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Queue<T>
synchronizedEvictingQueue()
Create a new, synchronizedEvictingQueue
that can hold up toDEFAULT_MAX_RECENT_ITEMS
items.static <T> Queue<T>
synchronizedEvictingQueue(int maxSize)
Create a new, synchronizedEvictingQueue
that can hold up tomaxSize
items.
-
-
-
Field Detail
-
DEFAULT_MAX_RECENT_ITEMS
public static final int DEFAULT_MAX_RECENT_ITEMS
The default maximum number ofEvictingQueue
items.- See Also:
synchronizedEvictingQueue()
, Constant Field Values
-
-
Method Detail
-
synchronizedEvictingQueue
public static <T> Queue<T> synchronizedEvictingQueue()
Create a new, synchronizedEvictingQueue
that can hold up toDEFAULT_MAX_RECENT_ITEMS
items.- Type Parameters:
T
- the type in the queue- Returns:
- a synchronized
EvictingQueue
- See Also:
Queues.synchronizedQueue(Queue)
- API Note:
- returns a plain
Queue
because Guava'sQueues.synchronizedQueue(Queue)
returns aQueue
. Any attempt to cast to anEvictingQueue
will result in aClassCastException
. - Implementation Note:
- See synchronized notes regarding manual synchronization of the returned queue's
Iterator
inQueues.synchronizedQueue(Queue)
-
synchronizedEvictingQueue
public static <T> Queue<T> synchronizedEvictingQueue(int maxSize)
Create a new, synchronizedEvictingQueue
that can hold up tomaxSize
items.- Type Parameters:
T
- the type in the queue- Parameters:
maxSize
- maximum size for the queue- Returns:
- a synchronized
EvictingQueue
- See Also:
Queues.synchronizedQueue(Queue)
- API Note:
- returns a plain
Queue
because Guava'sQueues.synchronizedQueue(Queue)
returns aQueue
. Any attempt to cast to anEvictingQueue
will result in aClassCastException
. - Implementation Note:
- See synchronized notes regarding manual synchronization of the returned queue's
Iterator
inQueues.synchronizedQueue(Queue)
-
-