K
- the type of the cache entry keysV
- the type of the entry values in the back cache that is used
as the source for this view
public class ViewBuilder<K,V> extends Object
ViewBuilder
provides a means to build()
a view
(ContinuousQueryCache
)
using a fluent pattern / style.ContinuousQueryCache
Constructor and Description |
---|
ViewBuilder(NamedCache<K,V> cache)
Construct a new
ViewBuilder for the provided NamedCache . |
ViewBuilder(Supplier<NamedCache<K,V>> supplierNamedCache)
Construct a new
ViewBuilder for the provided NamedCache . |
Modifier and Type | Method and Description |
---|---|
NamedCache<K,V> |
build()
Construct a
view of the NamedCache provided to this builder. |
ViewBuilder<K,V> |
filter(Filter<?> filter)
The
Filter that will be used to define the entries maintained in this view. |
ViewBuilder<K,V> |
keys()
The resulting
view will only cache keys. |
ViewBuilder<K,V> |
listener(MapListener<? super K,? super V> listener)
The
MapListener that will receive all events, including those that
result from the initial population of the view . |
<U> ViewBuilder<K,U> |
map(ValueExtractor<? super V,? extends U> mapper)
The
ValueExtractor that this view will use to transform the results from
the underlying cache prior to storing them locally. |
ViewBuilder<K,V> |
values()
The resulting
view with cache both keys and values. |
ViewBuilder<K,V> |
withClassLoader(ClassLoader loader)
The optional
ClassLoader to use when performing serialization/de-serialization operations. |
public ViewBuilder(NamedCache<K,V> cache)
ViewBuilder
for the provided NamedCache
.cache
- the NamedCache
from which the view will be createdpublic ViewBuilder(Supplier<NamedCache<K,V>> 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> 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 NamedCache
ViewBuilder
public ViewBuilder<K,V> listener(MapListener<? super K,? super V> 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.ViewBuilder
public <U> ViewBuilder<K,U> map(ValueExtractor<? super V,? extends U> 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-only
ViewBuilder
public ViewBuilder<K,V> keys()
view
will only cache keys.
NOTE: this is mutually exclusive with values()
.ViewBuilder
public ViewBuilder<K,V> values()
view
with cache both keys and values.
NOTE: this is mutually exclusive with keys()
.ViewBuilder
public ViewBuilder<K,V> withClassLoader(ClassLoader loader)
ClassLoader
to use when performing serialization/de-serialization operations.loader
- the ClassLoader
ViewBuilder
public NamedCache<K,V> build()
view
of the NamedCache
provided to this builder.view
of the NamedCache
provided to this builder