Package org.kiwiproject.collect
Class KiwiEvictingQueues
- java.lang.Object
-
- org.kiwiproject.collect.KiwiEvictingQueues
-
public class KiwiEvictingQueues extends Object
Utility methods for working with GuavaEvictingQueueinstances.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_RECENT_ITEMSThe default maximum number ofEvictingQueueitems.
-
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, synchronizedEvictingQueuethat can hold up toDEFAULT_MAX_RECENT_ITEMSitems.static <T> Queue<T>synchronizedEvictingQueue(int maxSize)Create a new, synchronizedEvictingQueuethat can hold up tomaxSizeitems.
-
-
-
Field Detail
-
DEFAULT_MAX_RECENT_ITEMS
public static final int DEFAULT_MAX_RECENT_ITEMS
The default maximum number ofEvictingQueueitems.- See Also:
synchronizedEvictingQueue(), Constant Field Values
-
-
Method Detail
-
synchronizedEvictingQueue
public static <T> Queue<T> synchronizedEvictingQueue()
Create a new, synchronizedEvictingQueuethat can hold up toDEFAULT_MAX_RECENT_ITEMSitems.- Type Parameters:
T- the type in the queue- Returns:
- a synchronized
EvictingQueue - See Also:
Queues.synchronizedQueue(Queue)- API Note:
- returns a plain
Queuebecause Guava'sQueues.synchronizedQueue(Queue)returns aQueue. Any attempt to cast to anEvictingQueuewill result in aClassCastException. - Implementation Note:
- See synchronized notes regarding manual synchronization of the returned queue's
IteratorinQueues.synchronizedQueue(Queue)
-
synchronizedEvictingQueue
public static <T> Queue<T> synchronizedEvictingQueue(int maxSize)
Create a new, synchronizedEvictingQueuethat can hold up tomaxSizeitems.- 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
Queuebecause Guava'sQueues.synchronizedQueue(Queue)returns aQueue. Any attempt to cast to anEvictingQueuewill result in aClassCastException. - Implementation Note:
- See synchronized notes regarding manual synchronization of the returned queue's
IteratorinQueues.synchronizedQueue(Queue)
-
-