public class GridNodeLocalMapImpl<K,V> extends org.jdk8.backport.ConcurrentHashMap8<K,V> implements GridNodeLocalMap<K,V>, Externalizable
org.jdk8.backport.ConcurrentHashMap8.Action<A>, org.jdk8.backport.ConcurrentHashMap8.BiAction<A,B>, org.jdk8.backport.ConcurrentHashMap8.BiFun<A,B,T>, org.jdk8.backport.ConcurrentHashMap8.DoubleByDoubleToDouble, org.jdk8.backport.ConcurrentHashMap8.DoubleToDouble, org.jdk8.backport.ConcurrentHashMap8.EntrySetView<K,V>, org.jdk8.backport.ConcurrentHashMap8.Fun<A,T>, org.jdk8.backport.ConcurrentHashMap8.Generator<T>, org.jdk8.backport.ConcurrentHashMap8.IntByIntToInt, org.jdk8.backport.ConcurrentHashMap8.IntToInt, org.jdk8.backport.ConcurrentHashMap8.KeySetView<K,V>, org.jdk8.backport.ConcurrentHashMap8.LongByLongToLong, org.jdk8.backport.ConcurrentHashMap8.LongToLong, org.jdk8.backport.ConcurrentHashMap8.ObjectByObjectToDouble<A,B>, org.jdk8.backport.ConcurrentHashMap8.ObjectByObjectToInt<A,B>, org.jdk8.backport.ConcurrentHashMap8.ObjectByObjectToLong<A,B>, org.jdk8.backport.ConcurrentHashMap8.ObjectToDouble<A>, org.jdk8.backport.ConcurrentHashMap8.ObjectToInt<A>, org.jdk8.backport.ConcurrentHashMap8.ObjectToLong<A>, org.jdk8.backport.ConcurrentHashMap8.Spliterator<T>, org.jdk8.backport.ConcurrentHashMap8.ValuesView<K,V>| Constructor and Description |
|---|
GridNodeLocalMapImpl()
No-arg constructor is required by externalization.
|
| Modifier and Type | Method and Description |
|---|---|
V |
addIfAbsent(K key,
Callable<V> dflt)
Gets the value with given key.
|
V |
addIfAbsent(K key,
V val)
Unlike its sibling method
ConcurrentMap.putIfAbsent(Object, Object) this method returns
current mapping from the map. |
<V> V |
addMeta(String name,
V val)
Adds a new metadata.
|
<V> V |
addMetaIfAbsent(String name,
Callable<V> c)
Adds given metadata value only if it was absent.
|
<V> V |
addMetaIfAbsent(String name,
V val)
Adds given metadata value only if it was absent.
|
<V> Map<String,V> |
allMeta()
Gets all metadata in this entry.
|
void |
copyMeta(GridMetadataAware from)
Copies all metadata from another instance.
|
void |
copyMeta(Map<String,?> data)
Copies all metadata from given map.
|
boolean |
hasMeta(String name)
Tests whether or not given metadata is set.
|
<V> boolean |
hasMeta(String name,
V val)
Tests whether or not metadata with given name and value is set.
|
<V> V |
meta(String name)
Gets metadata by name.
|
<V> V |
putMetaIfAbsent(String name,
Callable<V> c)
Adds given metadata value only if it was absent.
|
<V> V |
putMetaIfAbsent(String name,
V val)
Adds given metadata value only if it was absent.
|
void |
readExternal(ObjectInput in) |
protected Object |
readResolve()
Reconstructs object on demarshalling.
|
<V> V |
removeMeta(String name)
Removes metadata by name.
|
<V> boolean |
removeMeta(String name,
V val)
Removes metadata only if its current value is equal to
val passed in. |
<V> boolean |
replaceMeta(String name,
V curVal,
V newVal)
Replaces given metadata with new
newVal value only if its current value
is equal to curVal. |
String |
toString() |
void |
writeExternal(ObjectOutput out) |
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, entrySpliterator, equals, get, getValueOrDefault, hashCode, isEmpty, keys, keySet, keySet, keySpliterator, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, remove, remove, replace, replace, size, values, valueSpliteratorclone, finalize, getClass, notify, notifyAll, wait, wait, waitputIfAbsent, remove, replace, replacepublic GridNodeLocalMapImpl()
@Nullable public V addIfAbsent(K key, @Nullable Callable<V> dflt)
null
return null.addIfAbsent in interface GridNodeLocalMap<K,V>key - Key to get the value for.dflt - Default value producing closure.null if key is not found and
closure is null.public V addIfAbsent(K key, V val)
ConcurrentMap.putIfAbsent(Object, Object) this method returns
current mapping from the map.addIfAbsent in interface GridNodeLocalMap<K,V>key - Key.val - Value to put if one does not exist.public <V> V addMeta(String name, V val)
addMeta in interface GridMetadataAwareV - Type of the value.name - Metadata name.val - Metadata value.null if there was none.public <V> V putMetaIfAbsent(String name, V val)
putMetaIfAbsent in interface GridMetadataAwareV - Type of the value.name - Metadata name.val - Value to add if it's not attached already.null if new value was put, or current value if put didn't happen.public <V> V putMetaIfAbsent(String name, Callable<V> c)
putMetaIfAbsent in interface GridMetadataAwareV - Type of the value.name - Metadata name.c - Factory closure to produce value to add if it's not attached already.
Not that unlike GridMetadataAware.addMeta(String, Object) method the factory closure will
not be called unless the value is required and therefore value will only be created
when it is actually needed.null if new value was put, or current value if put didn't happen.public <V> V addMetaIfAbsent(String name, V val)
GridMetadataAware.putMetaIfAbsent(String, Callable), this method always returns
the latest value and never previous one.addMetaIfAbsent in interface GridMetadataAwareV - Type of the value.name - Metadata name.val - Value to add if it's not attached already.public <V> V addMetaIfAbsent(String name, Callable<V> c)
addMetaIfAbsent in interface GridMetadataAwareV - Type of the value.name - Metadata name.c - Factory closure to produce value to add if it's not attached already.
Not that unlike GridMetadataAware.addMeta(String, Object) method the factory closure will
not be called unless the value is required and therefore value will only be created
when it is actually needed. If null and metadata value is missing - null
will be returned from this method.@Nullable public <V> V meta(String name)
meta in interface GridMetadataAwareV - Type of the value.name - Metadata name.null.@Nullable public <V> V removeMeta(String name)
removeMeta in interface GridMetadataAwareV - Type of the value.name - Name of the metadata to remove.null.public <V> boolean removeMeta(String name, V val)
val passed in.removeMeta in interface GridMetadataAwareV - Value type.name - Name of metadata attribute.val - Value to compare.True if value was removed, false otherwise.public <V> Map<String,V> allMeta()
allMeta in interface GridMetadataAwareV - Type of the value.public boolean hasMeta(String name)
hasMeta in interface GridMetadataAwarename - Name of the metadata to test.public <V> boolean hasMeta(String name, V val)
true if
attachment with given name it set and its value is equals to provided value. Otherwise returns
false.hasMeta in interface GridMetadataAwareV - Type of the value.name - Name of the metadata.val - Value to compare. Cannot be null.true if metadata with given name is set and its value is equals to provided value -
otherwise returns false.public <V> boolean replaceMeta(String name, V curVal, V newVal)
newVal value only if its current value
is equal to curVal. Otherwise, it is no-op.replaceMeta in interface GridMetadataAwarename - Name of the metadata.curVal - Current value to check.newVal - New value.true if replacement occurred, false otherwise.public void copyMeta(GridMetadataAware from)
copyMeta in interface GridMetadataAwarefrom - Metadata aware instance to copy metadata from.public void copyMeta(Map<String,?> data)
copyMeta in interface GridMetadataAwaredata - Map to copy metadata from.public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionprotected Object readResolve() throws ObjectStreamException
ObjectStreamException - Thrown in case of demarshalling error.Copyright © 2014. All rights reserved.