Class ConverterCollections.ConverterInvocableMap<FK,TK,FV,TV>

java.lang.Object
com.tangosol.util.ConverterCollections.ConverterMap<FK,TK,FV,TV>
com.tangosol.util.ConverterCollections.ConverterInvocableMap<FK,TK,FV,TV>
All Implemented Interfaces:
InvocableMap<TK,TV>, Serializable, Map<TK,TV>
Enclosing class:
ConverterCollections

public static class ConverterCollections.ConverterInvocableMap<FK,TK,FV,TV> extends ConverterCollections.ConverterMap<FK,TK,FV,TV> implements InvocableMap<TK,TV>, Serializable
A Converter InvocableMap views an underlying InvocableMap through a set of key and value Converters.
See Also:
  • Constructor Details

    • ConverterInvocableMap

      public ConverterInvocableMap(InvocableMap<FK,FV> map, Converter<FK,TK> convKeyUp, Converter<TK,FK> convKeyDown, Converter<FV,TV> convValUp, Converter<TV,FV> convValDown)
      Constructor.
      Parameters:
      map - the underlying InvocableMap
      convKeyUp - the Converter to view the underlying InvocableMap's keys through
      convKeyDown - the Converter to use to pass keys down to the underlying InvocableMap
      convValUp - the Converter to view the underlying InvocableMap's values through
      convValDown - the Converter to use to pass values down to the underlying InvocableMap
  • Method Details

    • aggregate

      public <R> R aggregate(Collection<? extends TK> collKeys, InvocableMap.EntryAggregator<? super TK,? super TV,R> agent)
      Perform an aggregating operation against the entries specified by the passed keys.
      Specified by:
      aggregate in interface InvocableMap<FK,TK>
      Type Parameters:
      R - the type of value returned by the EntryAggregator
      Parameters:
      collKeys - the Collection of keys that specify the entries within this Map to aggregate across
      agent - the EntryAggregator that is used to aggregate across the specified entries of this Map
      Returns:
      the result of the aggregation
    • aggregate

      public <R> R aggregate(Filter filter, InvocableMap.EntryAggregator<? super TK,? super TV,R> agent)
      Perform an aggregating operation against the set of entries that are selected by the given Filter.
      Specified by:
      aggregate in interface InvocableMap<FK,TK>
      Type Parameters:
      R - the type of value returned by the EntryAggregator
      Parameters:
      filter - the Filter that is used to select entries within this Map to aggregate across
      agent - the EntryAggregator that is used to aggregate across the selected entries of this Map
      Returns:
      the result of the aggregation
    • invoke

      public <R> R invoke(TK key, InvocableMap.EntryProcessor<TK,TV,R> agent)
      Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation.
      Specified by:
      invoke in interface InvocableMap<FK,TK>
      Type Parameters:
      R - the type of value returned by the EntryProcessor
      Parameters:
      key - the key to process; it is not required to exist within the Map
      agent - the EntryProcessor to use to process the specified key
      Returns:
      the result of the invocation as returned from the EntryProcessor
    • invokeAll

      public <R> Map<TK,R> invokeAll(Collection<? extends TK> collKeys, InvocableMap.EntryProcessor<TK,TV,R> agent)
      Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.
      Specified by:
      invokeAll in interface InvocableMap<FK,TK>
      Type Parameters:
      R - the type of value returned by the EntryProcessor
      Parameters:
      collKeys - the keys to process; these keys are not required to exist within the Map
      agent - the EntryProcessor to use to process the specified keys
      Returns:
      a Map containing the results of invoking the EntryProcessor against each of the specified keys
    • invokeAll

      public <R> Map<TK,R> invokeAll(Filter filter, InvocableMap.EntryProcessor<TK,TV,R> agent)
      Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter, returning the result of the invocation for each.

      Unless specified otherwise, InvocableMap implementations will perform this operation in two steps: (1) use the filter to retrieve a matching entry set; (2) apply the agent to every filtered entry. This algorithm assumes that the agent's processing does not affect the result of the specified filter evaluation, since the filtering and processing could be performed in parallel on different threads. If this assumption does not hold, the processor logic has to be idempotent, or at least re-evaluate the filter. This could be easily accomplished by wrapping the processor with the ConditionalProcessor.

      Specified by:
      invokeAll in interface InvocableMap<FK,TK>
      Type Parameters:
      R - the type of value returned by the EntryProcessor
      Parameters:
      filter - a Filter that results in the set of keys to be processed
      agent - the EntryProcessor to use to process the specified keys
      Returns:
      a Map containing the results of invoking the EntryProcessor against the keys that are selected by the given Filter
    • putIfAbsent

      public TV putIfAbsent(TK key, TV value)
      Specified by:
      putIfAbsent in interface InvocableMap<FK,TK>
      Specified by:
      putIfAbsent in interface Map<FK,TK>
    • remove

      public boolean remove(Object key, Object value)
      Specified by:
      remove in interface InvocableMap<FK,TK>
      Specified by:
      remove in interface Map<FK,TK>
    • replace

      public boolean replace(TK key, TV oldValue, TV newValue)
      Specified by:
      replace in interface InvocableMap<FK,TK>
      Specified by:
      replace in interface Map<FK,TK>
    • replace

      public TV replace(TK key, TV value)
      Specified by:
      replace in interface InvocableMap<FK,TK>
      Specified by:
      replace in interface Map<FK,TK>
    • merge

      public TV merge(TK key, TV value, Remote.BiFunction<? super TV,? super TV,? extends TV> remappingFunction)
      Description copied from interface: InvocableMap
      If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value. Otherwise, replaces the associated value with the results of the given remapping function, or removes if the result is null.

      This method may be of use when combining multiple mapped values for a key. For example, to either create or append a String msg to a value mapping:

       
       map.merge(key, msg, String::concat)
       
      If the function returns null the mapping is removed. If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.
      Specified by:
      merge in interface InvocableMap<FK,TK>
      Parameters:
      key - key with which the resulting value is to be associated
      value - the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the key
      remappingFunction - the function to recompute a value if present
      Returns:
      the new value associated with the specified key, or null if no value is associated with the key
    • merge

      public TV merge(TK key, TV value, BiFunction<? super TV,? super TV,? extends TV> remappingFunction)
      Specified by:
      merge in interface InvocableMap<FK,TK>
      Specified by:
      merge in interface Map<FK,TK>
    • getInvocableMap

      public InvocableMap<FK,FV> getInvocableMap()
      Return the underlying InvocableMap.
      Returns:
      the underlying InvocableMap
    • convertSafe

      protected static Object convertSafe(Converter converter, Object oValue)
      Convert the provided value with the given converter. If there is an issue in type conversion return the given value.
      Parameters:
      converter - the converter to use
      oValue - the value to convert
      Returns:
      a converted value or the original value