K - the type of the cache entry keysV_BACK - the type of the entry values in the back cache that is used
as the source for this viewV_FRONT - the type of the entry values in this view, which
will be the same as V_BACK, unless a transformer is specified
when creating this viewpublic class ViewBuilder<K,V_BACK,V_FRONT> extends Object
ViewBuilder provides a means to build() a view (ContinuousQueryCache)
using a fluent pattern / style.ContinuousQueryCache| Constructor and Description |
|---|
ViewBuilder(NamedCache<K,V_BACK> cache)
Construct a new
ViewBuilder for the provided NamedCache. |
ViewBuilder(Supplier<NamedCache<K,V_BACK>> supplierNamedCache)
Construct a new
ViewBuilder for the provided NamedCache. |
| Modifier and Type | Method and Description |
|---|---|
NamedCache<K,V_FRONT> |
build()
Construct a
view of the NamedCache provided to this builder. |
ViewBuilder<K,V_BACK,V_FRONT> |
filter(Filter filter)
The
Filter that will be used to define the entries maintained in this view. |
ViewBuilder<K,V_BACK,V_FRONT> |
keys()
The resulting
view will only cache keys. |
ViewBuilder<K,V_BACK,V_FRONT> |
listener(MapListener<? super K,? super V_FRONT> listener)
The
MapListener that will receive all events, including those that
result from the initial population of the view. |
ViewBuilder<K,V_BACK,V_FRONT> |
map(ValueExtractor<? super V_BACK,? extends V_FRONT> mapper)
The
ValueExtractor that this view will use to transform the results from
the underlying cache prior to storing them locally. |
ViewBuilder<K,V_BACK,V_FRONT> |
values()
The resulting
view with cache both keys and values. |
ViewBuilder<K,V_BACK,V_FRONT> |
withClassLoader(ClassLoader loader)
The optional
ClassLoader to use when performing serialization/de-serialization operations. |
public ViewBuilder(NamedCache<K,V_BACK> cache)
ViewBuilder for the provided NamedCache.cache - the NamedCache from which the view will be createdpublic ViewBuilder(Supplier<NamedCache<K,V_BACK>> supplierNamedCache)
ViewBuilder for the provided NamedCache.
The Supplier should return a new NamedCache instance upon
each invocation.supplierNamedCache - the Supplier returning a NamedCache
from which the view will be createdpublic ViewBuilder<K,V_BACK,V_FRONT> filter(Filter filter)
Filter that will be used to define the entries maintained in this view.
If no Filter is specified, AlwaysFilter.INSTANCE will be used.filter - the Filter that will be used to query the
underlying NamedCacheViewBuilderpublic ViewBuilder<K,V_BACK,V_FRONT> listener(MapListener<? super K,? super V_FRONT> listener)
MapListener that will receive all events, including those that
result from the initial population of the view.listener - the MapListener that will receive all the events from
the view, including those corresponding to its initial
population.ViewBuilderpublic ViewBuilder<K,V_BACK,V_FRONT> map(ValueExtractor<? super V_BACK,? extends V_FRONT> mapper)
ValueExtractor that this view will use to transform the results from
the underlying cache prior to storing them locally.mapper - the ValueExtractor that will be used to
transform values retrieved from the underlying cache
before storing them locally; if specified, this
view will become read-onlyViewBuilderpublic ViewBuilder<K,V_BACK,V_FRONT> keys()
view will only cache keys.
NOTE: this is mutually exclusive with values().ViewBuilderpublic ViewBuilder<K,V_BACK,V_FRONT> values()
view with cache both keys and values.
NOTE: this is mutually exclusive with keys().ViewBuilderpublic ViewBuilder<K,V_BACK,V_FRONT> withClassLoader(ClassLoader loader)
ClassLoader to use when performing serialization/de-serialization operations.loader - the ClassLoaderViewBuilderpublic NamedCache<K,V_FRONT> build()
view of the NamedCache provided to this builder.view of the NamedCache provided to this builder