Interface InvocableMap.Entry<K,V>
-
- Type Parameters:
K
- the type of the Map entry keyV
- the type of the Map entry value
- All Superinterfaces:
Map.Entry<K,V>
,QueryMap.Entry<K,V>
- All Known Subinterfaces:
BinaryEntry<K,V>
,MapTrigger.Entry<K,V>
- All Known Implementing Classes:
AbstractKeyBasedMap.EntrySet.Entry
,BackingMapBinaryEntry
,BinaryMap.Entry
,ConverterCollections.ConverterMapEvent.ConverterMapEventBinaryEntry
,InvocableMapHelper.RoutingBinaryEntry
,InvocableMapHelper.RoutingMapTriggerEntry
,InvocableMapHelper.SimpleEntry
,ObservableSplittingBackingCache.EntrySet.Entry
,OpenHashMap.EntrySet.Entry
,ReadWriteBackingMap.Entry
,SerializationCache.EntrySet.Entry
,SimpleElement.AttributeMap.Entry
,SimpleMapEntry
- Enclosing interface:
- InvocableMap<K,V>
public static interface InvocableMap.Entry<K,V> extends QueryMap.Entry<K,V>
An InvocableMap.Entry contains additional information and exposes additional operations that the basic Map.Entry does not. It allows non-existent entries to be represented, thus allowing their optional creation. It allows existent entries to be removed from the Map. It supports a number of optimizations that can ultimately be mapped through to indexes and other data structures of the underlying Map.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default BinaryEntry<K,V>
asBinaryEntry()
Return this entry as aBinaryEntry
.K
getKey()
Return the key corresponding to this entry.V
getValue()
Return the value corresponding to this entry.default V
getValue(Supplier<V> defaultValueSupplier)
Return the value corresponding to this entry, or the default value returned by thedefaultValueSupplier
, if the entry value isnull
.default V
getValue(V defaultValue)
Return the value corresponding to this entry, or the specifieddefaultValue
, if the entry value isnull
.boolean
isPresent()
Determine if this Entry exists in the Map.boolean
isSynthetic()
Determine if this Entry has been synthetically mutated.void
remove(boolean fSynthetic)
Remove this Entry from the Map if it is present in the Map.V
setValue(V value)
Store the value corresponding to this entry.void
setValue(V value, boolean fSynthetic)
Store the value corresponding to this entry.<T> void
update(ValueUpdater<V,T> updater, T value)
Update the Entry's value.-
Methods inherited from interface com.tangosol.util.QueryMap.Entry
extract, extractFromKey, extractFromValue
-
-
-
-
Method Detail
-
getKey
K getKey()
Return the key corresponding to this entry. The resultant key does not necessarily exist within the containing Map, which is to say that InvocableMap.this.containsKey(getKey()) could return false. To test for the presence of this key within the Map, useisPresent()
, and to create the entry for the key, usesetValue(V)
.
-
getValue
V getValue()
Return the value corresponding to this entry. If the entry does not exist, then the value will be null. To differentiate between a null value and a non-existent entry, useisPresent()
.Note: any modifications to the value retrieved using this method are not guaranteed to persist unless followed by a
setValue(V)
orupdate(com.tangosol.util.ValueUpdater<V, T>, T)
call.
-
setValue
V setValue(V value)
Store the value corresponding to this entry. If the entry does not exist, then the entry will be created by invoking this method, even with a null value (assuming the Map supports null values).
-
getValue
default V getValue(V defaultValue)
Return the value corresponding to this entry, or the specifieddefaultValue
, if the entry value isnull
. To differentiate between a null value and a non-existent entry, useisPresent()
.Note: any modifications to the value retrieved using this method are not guaranteed to persist unless followed by a
setValue(V)
orupdate(com.tangosol.util.ValueUpdater<V, T>, T)
call.- Parameters:
defaultValue
- the default value to return if the entry value isnull
- Returns:
- the value corresponding to this entry, or the specified
defaultValue
, if the entry value isnull
-
getValue
default V getValue(Supplier<V> defaultValueSupplier)
Return the value corresponding to this entry, or the default value returned by thedefaultValueSupplier
, if the entry value isnull
. To differentiate between a null value and a non-existent entry, useisPresent()
.Note: any modifications to the value retrieved using this method are not guaranteed to persist unless followed by a
setValue(V)
orupdate(com.tangosol.util.ValueUpdater<V, T>, T)
call.- Parameters:
defaultValueSupplier
- the default value supplier to use to create the default value if the entry value isnull
- Returns:
- the value corresponding to this entry, or the value created
by the specified
defaultValueSupplier
, if the entry value isnull
- Since:
- 21.12
-
setValue
void setValue(V value, boolean fSynthetic)
Store the value corresponding to this entry. If the entry does not exist, then the entry will be created by invoking this method, even with a null value (assuming the Map supports null values).Unlike the other form of
setValue
, this form does not return the previous value, and as a result may be significantly less expensive (in terms of cost of execution) for certain Map implementations.- Parameters:
value
- the new value for this EntryfSynthetic
- pass true only if the insertion into or modification of the Map should be treated as a synthetic event
-
update
<T> void update(ValueUpdater<V,T> updater, T value)
Update the Entry's value. Calling this method is semantically equivalent to:V target = entry.getValue(); updater.update(target, value); entry.setValue(target, false);
The benefit of using this method is that it may allow the Entry implementation to significantly optimize the operation, such as for purposes of delta updates and backup maintenance.- Type Parameters:
T
- the class of the value- Parameters:
updater
- a ValueUpdater used to modify the Entry's valuevalue
- the new value for this Entry
-
isPresent
boolean isPresent()
Determine if this Entry exists in the Map. If the Entry is not present, it can be created by callingsetValue(Object)
orsetValue(Object, boolean)
. If the Entry is present, it can be destroyed by callingremove(boolean)
.- Returns:
- true iff this Entry is existent in the containing Map
-
isSynthetic
boolean isSynthetic()
Determine if this Entry has been synthetically mutated. This method returnsfalse
if either a non-synthetic update was made or the entry has not been modified.- Returns:
- true if the Entry has been synthetically mutated
-
remove
void remove(boolean fSynthetic)
Remove this Entry from the Map if it is present in the Map.This method supports both the operation corresponding to
Map.remove(java.lang.Object)
as well as synthetic operations such as eviction. If the containing Map does not differentiate between the two, then this method will always be identical to InvocableMap.this.remove(getKey()).- Parameters:
fSynthetic
- pass true only if the removal from the Map should be treated as a synthetic event
-
asBinaryEntry
default BinaryEntry<K,V> asBinaryEntry()
Return this entry as aBinaryEntry
.This is a convenience method that allows you to avoid casting an
Entry
into aBinaryEntry
within anInvocableMap.EntryProcessor
implementation. It will *not* attempt to coerce this instance into aBinaryEntry
.- Returns:
- this entry as a
BinaryEntry
- Throws:
ClassCastException
- if this entry is not an instance of aBinaryEntry
- Since:
- 20.12
-
-