public static class ConverterCollections.ConverterInvocableMap<FK,TK,FV,TV> extends ConverterCollections.ConverterMap<FK,TK,FV,TV> implements InvocableMap<TK,TV>, Serializable
InvocableMap.Entry<K,V>, InvocableMap.EntryAggregator<K,V,R>, InvocableMap.EntryProcessor<K,V,R>, InvocableMap.ParallelAwareAggregator<K,V,P,R>, InvocableMap.StreamingAggregator<K,V,P,R>
m_convKeyDown, m_convKeyUp, m_convValDown, m_convValUp, m_map, m_set
Constructor and Description |
---|
ConverterInvocableMap(InvocableMap<FK,FV> map,
Converter<FK,TK> convKeyUp,
Converter<TK,FK> convKeyDown,
Converter<FV,TV> convValUp,
Converter<TV,FV> convValDown)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<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.
|
<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.
|
protected static Object |
convertSafe(Converter converter,
Object oValue)
Convert the provided value with the given converter.
|
InvocableMap<FK,FV> |
getInvocableMap()
Return the underlying InvocableMap.
|
<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.
|
<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.
|
<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.
|
TV |
merge(TK key,
TV value,
BiFunction<? super TV,? super TV,? extends TV> remappingFunction) |
TV |
merge(TK key,
TV value,
Remote.BiFunction<? super TV,? super TV,? extends TV> remappingFunction)
If the specified key is not already associated with a value or is
associated with null, associates it with the given non-null value.
|
TV |
putIfAbsent(TK key,
TV value) |
boolean |
remove(Object key,
Object value) |
TV |
replace(TK key,
TV value) |
boolean |
replace(TK key,
TV oldValue,
TV newValue) |
clear, containsKey, containsValue, entrySet, equals, get, getConverterKeyDown, getConverterKeyUp, getConverterValueDown, getConverterValueUp, getMap, hashCode, instantiateCollection, instantiateEntrySet, instantiateMap, instantiateSet, isEmpty, keySet, put, putAll, remove, size, toString, values
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
aggregate, compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getOrDefault, invokeAll, replaceAll, replaceAll, replaceAll, replaceAll, stream, stream, stream, stream, stream, stream
public ConverterInvocableMap(InvocableMap<FK,FV> map, Converter<FK,TK> convKeyUp, Converter<TK,FK> convKeyDown, Converter<FV,TV> convValUp, Converter<TV,FV> convValDown)
map
- the underlying InvocableMapconvKeyUp
- the Converter to view the underlying
InvocableMap's keys throughconvKeyDown
- the Converter to use to pass keys down to the
underlying InvocableMapconvValUp
- the Converter to view the underlying
InvocableMap's values throughconvValDown
- the Converter to use to pass values down to the
underlying InvocableMappublic <R> R aggregate(Collection<? extends TK> collKeys, InvocableMap.EntryAggregator<? super TK,? super TV,R> agent)
aggregate
in interface InvocableMap<TK,TV>
R
- the type of value returned by the EntryAggregatorcollKeys
- the Collection of keys that specify the entries within
this Map to aggregate acrossagent
- the EntryAggregator that is used to aggregate across
the specified entries of this Mappublic <R> R aggregate(Filter filter, InvocableMap.EntryAggregator<? super TK,? super TV,R> agent)
aggregate
in interface InvocableMap<TK,TV>
R
- the type of value returned by the EntryAggregatorfilter
- the Filter that is used to select entries within this
Map to aggregate acrossagent
- the EntryAggregator that is used to aggregate across
the selected entries of this Mappublic <R> R invoke(TK key, InvocableMap.EntryProcessor<TK,TV,R> agent)
invoke
in interface InvocableMap<TK,TV>
R
- the type of value returned by the EntryProcessorkey
- the key to process; it is not required to exist within
the Mapagent
- the EntryProcessor to use to process the specified keypublic <R> Map<TK,R> invokeAll(Collection<? extends TK> collKeys, InvocableMap.EntryProcessor<TK,TV,R> agent)
invokeAll
in interface InvocableMap<TK,TV>
R
- the type of value returned by the EntryProcessorcollKeys
- the keys to process; these keys are not required to
exist within the Mapagent
- the EntryProcessor to use to process the specified keyspublic <R> Map<TK,R> invokeAll(Filter filter, InvocableMap.EntryProcessor<TK,TV,R> agent)
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
.
invokeAll
in interface InvocableMap<TK,TV>
R
- the type of value returned by the EntryProcessorfilter
- a Filter that results in the set of keys to be
processedagent
- the EntryProcessor to use to process the specified keyspublic TV putIfAbsent(TK key, TV value)
putIfAbsent
in interface InvocableMap<TK,TV>
putIfAbsent
in interface Map<TK,TV>
public TV merge(TK key, TV value, Remote.BiFunction<? super TV,? super TV,? extends TV> remappingFunction)
InvocableMap
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.merge
in interface InvocableMap<TK,TV>
key
- key with which the resulting value is to be associatedvalue
- 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 keyremappingFunction
- the function to recompute a value if presentpublic TV merge(TK key, TV value, BiFunction<? super TV,? super TV,? extends TV> remappingFunction)
public InvocableMap<FK,FV> getInvocableMap()
protected static Object convertSafe(Converter converter, Object oValue)
converter
- the converter to useoValue
- the value to convert