Class ResultsMap<K,V>

java.lang.Object
org.jppf.utils.ResultsMap<K,V>
Type Parameters:
K - the type of the keys in this map.
V - the type of non-exceptional values in this map.
All Implemented Interfaces:
Serializable

public class ResultsMap<K,V> extends Object implements Serializable
This class provides convenient methods to inspect and access a mapping of InvocationResult instances to specified keys.
Author:
Laurent Cohen
See Also:
  • Constructor Details

    • ResultsMap

      public ResultsMap()
  • Method Details

    • put

      public InvocationResult<V> put(K key, V value)
      Add an entry to this map.
      Parameters:
      key - the entry key.
      value - the entry's value.
      Returns:
      the value previously mapped to the key, or null if there wasn't any.
    • put

      public InvocationResult<V> put(K key, Exception exception)
      Add an entry with an exceptional value to this map.
      Parameters:
      key - the entry key.
      exception - the value as an Exception.
      Returns:
      the value previously mapped to the key, or null if there wasn't any.
    • put

      public InvocationResult<V> put(K key, InvocationResult<V> value)
      Add an entry to this map.
      Parameters:
      key - the entry key.
      value - the entry's value.
      Returns:
      the value previously mapped to the key, or null if there wasn't any.
    • get

      public InvocationResult<V> get(K key)
      Get the value of the entry with the specified key.
      Parameters:
      key - the key to look for.
      Returns:
      an InvocationResult if one is mapped to the key, null otherwise.
    • getResult

      public V getResult(K key)
      Get the unwrapped value of the entry with the specified key.
      Parameters:
      key - the key to look for.
      Returns:
      the value for the key, if an entry is mapped to the key, or null if there is no entry for the key or if the entry has an exception result.
    • getException

      public Exception getException(K key)
      Get the unwrapped exception of the entry with the specified key.
      Parameters:
      key - the key to look for.
      Returns:
      the exception for the key, if an entry is mapped to the key, or null if there is no entry for the key or if the entry has a non-exception result.
    • containsKey

      public boolean containsKey(K key)
      Determines whether this map contains an entry for the specified key.
      Parameters:
      key - the key to look for.
      Returns:
      true if there is an entry for the key, false otherwise.
    • entrySet

      public Set<Map.Entry<K,InvocationResult<V>>> entrySet()
      Get the entry set for all wrapped entries in this map.
      Returns:
      a set of entries mapping the keys in this map to the corresponding InvocationResults.
    • resultsEntrySet

      public Set<Map.Entry<K,V>> resultsEntrySet()
      Get the entry set for all unwrapped non-exception results in this map.
      Returns:
      a set of entries mapping the keys in this map to the corresponding unwrapped result.
    • exceptionsEntrySet

      public Set<Map.Entry<K,Exception>> exceptionsEntrySet()
      Get the entry set for all unwrapped exceptions in this map.
      Returns:
      a set of entries mapping the keys in this map to the corresponding exception.
    • forEach

      public void forEach(BiConsumer<K,InvocationResult<V>> action)
      Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.
      Parameters:
      action - the action to perform for each entry
    • keySet

      public Set<K> keySet()
      Get the set of all keys in this map.
      Returns:
      the set of keys in this map.
    • values

      public Collection<InvocationResult<V>> values()
      Get the values of all entries in this map.
      Returns:
      the set of values in the map.
    • results

      public Set<V> results()
      Get the unwrapped results of all entries in this map with a non-exception result.
      Returns:
      the set of all results in the map.
    • exceptions

      public Set<Exception> exceptions()
      Get the unwrapped exceptions of all entries in this map with an exceptional result.
      Returns:
      the set of all exceptions in the map.
    • size

      public int size()
      Returns:
      the size of this map.
    • isEmpty

      public boolean isEmpty()
      Determine whether this map is empty.
      Returns:
      ture if this map is empty, false otherwise.