public class GridMetadataAwareAdapter extends Object implements GridMetadataAware
GridMetadataAware.
| Constructor and Description |
|---|
GridMetadataAwareAdapter()
Default constructor.
|
GridMetadataAwareAdapter(Map<String,Object> data)
Creates adapter with predefined data.
|
| Modifier and Type | Method and Description |
|---|---|
<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.
|
Object |
clone() |
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.
|
protected void |
readExternalMeta(ObjectInput in)
Convenience way for super-classes which implement
Externalizable to
serialize metadata. |
<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. |
protected void |
writeExternalMeta(ObjectOutput out)
Convenience way for super-classes which implement
Externalizable to
serialize metadata. |
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.@Nullable 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.@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.@Nullable 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.@Nullable 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.@Nullable public <V> V addMetaIfAbsent(String name, @Nullable 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.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.protected void writeExternalMeta(ObjectOutput out) throws IOException
Externalizable to
serialize metadata. Super-classes must call this method explicitly from
within Externalizable.writeExternal(ObjectOutput) methods implementation.out - Output to write to.IOException - If I/O error occurred.protected void readExternalMeta(ObjectInput in) throws IOException, ClassNotFoundException
Externalizable to
serialize metadata. Super-classes must call this method explicitly from
within Externalizable.readExternal(ObjectInput) methods implementation.in - Input to read from.IOException - If I/O error occurred.ClassNotFoundException - If some class could not be found.Copyright © 2014. All rights reserved.