E - Type of enumerated elements.public final class CachedEnumerableState<E> extends Object
CachedEnumerable.CachedEnumerable| Modifier and Type | Field and Description |
|---|---|
CachedEnumerable<E> |
cachedSource
CachedEnumerable caching the instances of source. |
Consumer<CachedEnumerable<E>> |
callback
Method to call when the cache limit is reached.
|
long |
limit
Maximum size of the cache.
|
Enumerable<E> |
source
Enumerable instance providing the elements to cache. |
| Constructor and Description |
|---|
CachedEnumerableState(Enumerable<E> source,
CachedEnumerable<E> cachedSource,
long limit,
Consumer<CachedEnumerable<E>> callback)
Constructs a
CachedEnumerableState containing the given
source, cache size and callback. |
| Modifier and Type | Method and Description |
|---|---|
CachedEnumerableState<E> |
disable()
Gets a new
CachedEnumerableState instance identical to the
current one with the exception of having caching disabled. |
CachedEnumerableState<E> |
enable()
Gets a new
CachedEnumerableState instance identical to the
current one with the exception of having caching enabled. |
Enumerator<E> |
enumerator()
Gets an
Enumerator instance that enumerates over the cached
elements if caching is enabled or over the source Enumerable
if caching is disabled. |
boolean |
isDisabled()
Gets whether the caching is disabled.
|
boolean |
onceOnly()
Gets whether the source
Enumerable is a once only
enumerator. |
CachedEnumerableState<E> |
reset()
Gets a new
CachedEnumerableState instance identical to the
current one with the exception that it is reset. |
CachedEnumerableState<E> |
resize(long newLimit)
Gets a new
CachedEnumerableState instance identical to the
current one with the exception of a greater limit. |
public final Enumerable<E> source
Enumerable instance providing the elements to cache.public final CachedEnumerable<E> cachedSource
CachedEnumerable caching the instances of source.sourcepublic final long limit
callbackpublic final Consumer<CachedEnumerable<E>> callback
This method gets cachedSource as a parameter.
limitpublic CachedEnumerableState(Enumerable<E> source, CachedEnumerable<E> cachedSource, long limit, Consumer<CachedEnumerable<E>> callback)
CachedEnumerableState containing the given
source, cache size and callback.
This constructor builds a CachedEnumerableState that is
enabled by default.
source - Enumerable instance providing the elements to
cache.cachedSource - CachedEnumerable caching the elements of
source.limit - maximum cache size.callback - method to call when the cache limit is reached.public boolean isDisabled()
public CachedEnumerableState<E> enable()
CachedEnumerableState instance identical to the
current one with the exception of having caching enabled.CachedEnumerableState with caching enabled.isDisabled(),
disable()public CachedEnumerableState<E> disable()
CachedEnumerableState instance identical to the
current one with the exception of having caching disabled.CachedEnumerableState with caching disabled.isDisabled(),
enable()public CachedEnumerableState<E> reset()
CachedEnumerableState instance identical to the
current one with the exception that it is reset.CachedEnumerableState limit.resize(long)public CachedEnumerableState<E> resize(long newLimit)
CachedEnumerableState instance identical to the
current one with the exception of a greater limit.newLimit - value for the cache limit, larger than the current one.CachedEnumerableState limit.IllegalArgumentException - newLimit is not larger than
the current limit.reset()public boolean onceOnly()
Enumerable is a once only
enumerator.source.onceOnly().Enumerable.onceOnly()public Enumerator<E> enumerator()
Enumerator instance that enumerates over the cached
elements if caching is enabled or over the source Enumerable
if caching is disabled.Enumerator instance.CacheEnumerator,
Enumerable,
CachedEnumerableCopyright © 2016. All rights reserved.