T - the type contained in the cachepublic class CacheCollector<T> extends Object implements Collector<T,List<T>>
The values are returned oldest value first. When maxSize is reached, the oldest values are discarded.
| Constructor and Description |
|---|
CacheCollector(int maxSize)
A new cache collector with max size for the cache.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getMaxSize()
The maximum number of elements in the cache.
|
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 maximum size of the cache.
|
void |
writeValue(T newValue)
Takes the value and consumes it.
|
public CacheCollector(int maxSize)
maxSize - maximum number of elements in the cachepublic void setChangeNotification(Runnable notification)
CollectorsetChangeNotification in interface Collector<T,List<T>>public void writeValue(T newValue)
WriteFunctionwriteValue in interface WriteFunction<T>newValue - a valuepublic List<T> readValue()
ReadFunctionreadValue in interface ReadFunction<List<T>>public void setMaxSize(int maxSize)
If new maxSize is less than the current number of element in the cache, the old values are discarded.
maxSize - the maximum number of elements in the cache.public int getMaxSize()
Copyright © 2010–2015. All rights reserved.