T
- the type contained in the queuepublic class QueueCollector<T> extends Object implements Collector<T,List<T>>
Always returns new value as every read clears the cache. The values are returned oldest value first. When maxSize is reached, the oldest values are discarded.
Constructor and Description |
---|
QueueCollector(int maxSize)
New queue collector with the given max size for the queue.
|
Modifier and Type | Method and Description |
---|---|
int |
getMaxSize()
The maximum number of elements in the queue.
|
List<T> |
readValue()
Calculates, if needed, and then returns the value for this function.
|
void |
setChangeNotification(Runnable notification)
Task to run to notify of the presence of a new value in the collector.
|
void |
setMaxSize(int maxSize)
Changes the number of maximum values in the queue.
|
void |
writeValue(T newValue)
Takes the value and consumes it.
|
public QueueCollector(int maxSize)
maxSize
- maximum number of elements in the queuepublic void setChangeNotification(Runnable notification)
Collector
setChangeNotification
in interface Collector<T,List<T>>
public void writeValue(T newValue)
WriteFunction
writeValue
in interface WriteFunction<T>
newValue
- a valuepublic List<T> readValue()
ReadFunction
readValue
in interface ReadFunction<List<T>>
public void setMaxSize(int maxSize)
If new maxSize is less than the current number of element in the queue, the old values are discarded.
maxSize
- the maximum number of elements in the queuepublic int getMaxSize()
Copyright © 2010–2015. All rights reserved.