Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.util
Class InvocableMapHelper.SimpleEntry

    java.lang.Object
      com.tangosol.util.Base
          com.tangosol.util.InvocableMapHelper.SimpleEntry

All Implemented Interfaces:
  InvocableMap.Entry, QueryMap.Entry, java.util.Map.Entry

Enclosing class:
  InvocableMapHelper

    public static class InvocableMapHelper.SimpleEntry

extends Base
implements InvocableMap.Entry

Simple implementation of the InvocableMap.Entry interface. This assumes that the underlying Map content does not change while a reference to the SimpleEntry is alive and may cache the entry's value to avoid an extra map lookup.

Field Summary
`protected java.util.Map` | `m_map` The map.

Constructor Summary
`InvocableMapHelper.SimpleEntry(java.util.Map map, java.lang.Object oKey, boolean fReadOnly)` Construct a SimpleEntry for a given map and a key.
`InvocableMapHelper.SimpleEntry(java.lang.Object oKey, java.lang.Object oValue)` Construct a SimpleEntry for a given key and value.

Method Summary
`protected void` | `checkMutable()` Verify that this SimpleEntry is mutable.
`boolean` | `equals(java.lang.Object o)` Compare this SimpleEntry with another object for equality.
`java.lang.Object` | `extract(ValueExtractor extractor)` Extract a value out of the Entry's value.
`java.lang.Object` | `getKey()` Return the key corresponding to this entry.
`java.lang.Object` | `getValue()` Return the value corresponding to this entry.
`int` | `hashCode()` Return a hash code value for the SimpleEntry object.
`boolean` | `isPresent()` Determine if this Entry exists in the Map.
`void` | `remove(boolean fSynthetic)` Remove this Entry from the Map if it is present in the Map.
`java.lang.Object` | `setValue(java.lang.Object oValue)` Store the value corresponding to this entry.
`void` | `setValue(java.lang.Object oValue, boolean fSynthetic)` Store the value corresponding to this entry.
`java.lang.String` | `toString()` Provide a human-readable representation of the SimpleEntry object.
`void` | `update(ValueUpdater updater, java.lang.Object oValue)` Update the Entry's value.

Field Detail

### m_map

    protected java.util.Map m_map

  The map.

Constructor Detail

### InvocableMapHelper.SimpleEntry

    public InvocableMapHelper.SimpleEntry(java.util.Map map,
                                          java.lang.Object oKey,
                                          boolean fReadOnly)

  Construct a SimpleEntry for a given map and a key.

  Parameters:
    `map` - the parent Map for this entry
    `oKey` - the entry's key
    `fReadOnly` - if true, the entry will be marked as read-only, preventing the `setValue()` and `remove()` methods from modifying the underlying map's content

### InvocableMapHelper.SimpleEntry

    public InvocableMapHelper.SimpleEntry(java.lang.Object oKey,
                                          java.lang.Object oValue)

  Construct a SimpleEntry for a given key and value. The entry will be marked as read-only.

  Parameters:
    `oKey` - the entry's key
    `oValue` - the entry's value

Method Detail

### getKey

    public java.lang.Object 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, use `InvocableMap.Entry.isPresent()`, and to create the entry for the key, use `InvocableMap.Entry.setValue(java.lang.Object)`.

  Specified by:
    `getKey` in interface `InvocableMap.Entry`
  Specified by:
    `getKey` in interface `java.util.Map.Entry`
  Returns:
    the key corresponding to this entry; may be null if the underlying Map supports null keys

### getValue

    public java.lang.Object 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, use `InvocableMap.Entry.isPresent()`.

  Note: any modifications to the value retrieved using this method are not guaranteed to persist unless followed by a `InvocableMap.Entry.setValue(java.lang.Object)` or `InvocableMap.Entry.update(com.tangosol.util.ValueUpdater, java.lang.Object)` call.

  Specified by:
    `getValue` in interface `InvocableMap.Entry`
  Specified by:
    `getValue` in interface `java.util.Map.Entry`
  Returns:
    the value corresponding to this entry; may be null if the value is null or if the Entry does not exist in the Map

### setValue

    public java.lang.Object setValue(java.lang.Object oValue)

  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).

  Specified by:
    `setValue` in interface `InvocableMap.Entry`
  Specified by:
    `setValue` in interface `java.util.Map.Entry`
  Parameters:
    `oValue` - the new value for this Entry
  Returns:
    the previous value of this Entry, or null if the Entry did not exist

### setValue

    public void setValue(java.lang.Object oValue,
                         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.

  Specified by:
    `setValue` in interface `InvocableMap.Entry`
  Parameters:
    `oValue` - the new value for this Entry
    `fSynthetic` - pass true only if the insertion into or modification of the Map should be treated as a synthetic event

### extract

    public java.lang.Object extract(ValueExtractor extractor)

  Extract a value out of the Entry's value. Calling this method is semantically equivalent to `extractor.extract(entry.getValue())`, but this method may be significantly less expensive. For example, the resultant value may be obtained from a forward index, avoiding a potential object de-serialization.

  Specified by:
    `extract` in interface `QueryMap.Entry`
  Parameters:
    `extractor` - a ValueExtractor to apply to the Entry's value
  Returns:
    the extracted value

### update

    public void update(ValueUpdater updater,
                       java.lang.Object oValue)

  Update the Entry's value. Calling this method is semantically equivalent to:

         Object oTarget = entry.getValue();
         updater.update(oTarget, oValue);
         entry.setValue(oTarget, 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.

  Specified by:
    `update` in interface `InvocableMap.Entry`
  Parameters:
    `updater` - a ValueUpdater used to modify the Entry's value
    `oValue` - the new value for this Entry

### isPresent

    public boolean isPresent()

  Determine if this Entry exists in the Map. If the Entry is not present, it can be created by calling `InvocableMap.Entry.setValue(java.lang.Object)` or `InvocableMap.Entry.setValue(java.lang.Object)`. If the Entry is present, it can be destroyed by calling `InvocableMap.Entry.remove(boolean)`.

  Specified by:
    `isPresent` in interface `InvocableMap.Entry`
  Returns:
    true iff this Entry is existent in the containing Map

### remove

    public 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())`.

  Specified by:
    `remove` in interface `InvocableMap.Entry`
  Parameters:
    `fSynthetic` - pass true only if the removal from the Map should be treated as a synthetic event

### equals

    public boolean equals(java.lang.Object o)

  Compare this SimpleEntry with another object for equality.

  Specified by:
    `equals` in interface `java.util.Map.Entry`
  Parameters:
    `o` - an object reference or null
  Returns:
    true iff the passed object reference is a SimpleEntry object with the same key

### hashCode

    public int hashCode()

  Return a hash code value for the SimpleEntry object.

  Specified by:
    `hashCode` in interface `java.util.Map.Entry`

### toString

    public java.lang.String toString()

  Provide a human-readable representation of the SimpleEntry object.

  Returns:
    a String representation of this SimpleEntry object

### checkMutable

    protected void checkMutable()

  Verify that this SimpleEntry is mutable.

Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle. All rights reserved.