Class MapViewBuilder<K,V>

java.lang.Object
com.tangosol.net.MapViewBuilder<K,V>
Type Parameters:
K - the type of the map entry keys
V - the type of the entry values in the backing map that is used as the source for this view
Direct Known Subclasses:
ViewBuilder

public class MapViewBuilder<K,V> extends Object
The ViewBuilder provides a means to build() a map view using a fluent pattern / style.
Since:
20.06
Author:
Aleks Seovic 2020.06.06
  • Field Details

    • f_supplierNamedCache

      protected final Supplier<NamedCache<K,V>> f_supplierNamedCache
      The Supplier returning a NamedCache from which the view will be created.
    • m_filter

      protected Filter<?> m_filter
      The Filter that will be used to define the entries maintained in this view.
    • m_listener

      protected MapListener<? super K,? super V> m_listener
      The MapListener that will receive all the events from the view, including those corresponding to its initial population.
    • m_mapper

      protected ValueExtractor<? super V,?> m_mapper
      The ValueExtractor that will be used to transform values retrieved from the underlying map before storing them locally; if specified, this view will become read-only.
    • m_comparator

      protected Comparator<? super V> m_comparator
      The Comparator to use when creating a sorted view.
    • m_fCacheValues

      protected boolean m_fCacheValues
      Flag controlling if the view will store both keys and values or only keys. true by default.
    • m_loader

      protected ClassLoader m_loader
      The View's ClassLoader.
  • Constructor Details

  • Method Details

    • filter

      public MapViewBuilder<K,V> filter(Filter<?> filter)
      The Filter that will be used to define the entries maintained in this view. If no Filter is specified, AlwaysFilter.INSTANCE will be used.
      Parameters:
      filter - the Filter that will be used to query the underlying NamedMap
      Returns:
      this MapViewBuilder
    • listener

      public MapViewBuilder<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.
      Parameters:
      listener - the MapListener that will receive all the events from the view, including those corresponding to its initial population.
      Returns:
      this MapViewBuilder
    • map

      public <U> MapViewBuilder<K,U> map(ValueExtractor<? super V,? extends U> mapper)
      The ValueExtractor that this view will use to transform the results from the underlying map prior to storing them locally.
      Type Parameters:
      U - the type of the extracted value
      Parameters:
      mapper - the ValueExtractor that will be used to transform values retrieved from the underlying map before storing them locally; if specified, this view will become read-only
      Returns:
      this MapViewBuilder
    • sorted

      public MapViewBuilder<K,V> sorted()
      Ensure that the view is sorted based on the natural order of the values, which must implement Comparable interface.
      Returns:
      this MapViewBuilder
    • sorted

      public MapViewBuilder<K,V> sorted(Comparator<? super V> comparator)
      Ensure that the view is sorted using specified Comparator.
      Parameters:
      comparator - the Comparator that will be used to sort the entries in this view; if null, the entries will be sorted based on the natural order of the values, which must implement Comparable interface
      Returns:
      this MapViewBuilder
    • keys

      public MapViewBuilder<K,V> keys()
      The resulting view will only map keys.

      NOTE: this is mutually exclusive with values().
      Returns:
      this MapViewBuilder
    • values

      public MapViewBuilder<K,V> values()
      The resulting view with both map keys and values.

      NOTE: this is mutually exclusive with keys(), and the default.
      Returns:
      this MapViewBuilder
    • withClassLoader

      public MapViewBuilder<K,V> withClassLoader(ClassLoader loader)
      The optional ClassLoader to use when performing serialization/de-serialization operations.
      Parameters:
      loader - the ClassLoader
      Returns:
      this MapViewBuilder
    • build

      public NamedMap<K,V> build()
      Construct a view of the NamedMap provided to this builder.
      Returns:
      the view of the NamedMap provided to this builder