Package org.xmpp.util

Class ValueWrapper<V extends Serializable>

java.lang.Object
org.xmpp.util.ValueWrapper<V>
All Implemented Interfaces:
Serializable

@Immutable public class ValueWrapper<V extends Serializable> extends Object implements Serializable
A wrapper implementation for cached values, suitable for Map based caches where a significant portion of keys matches the corresponding value exactly.
Author:
Guus der Kinderen, guus.der.kinderen@gmail.com
See Also:
  • Constructor Details

    • ValueWrapper

      public ValueWrapper()
      Constructs an empty wrapper. This wrapper is used to indicate that the key that maps to this value is an exact duplicate of the generated value.
    • ValueWrapper

      public ValueWrapper(Exception exception)
      Constructs a wrapper that is used to indicate that the key that maps to this value cannot be used to generate a valid value
      Parameters:
      exception - Describes the invalidity of the key.
    • ValueWrapper

      public ValueWrapper(V value)
      Wraps a value while using the USE_VALUE representation.
      Parameters:
      value - The value that is wrapped.
  • Method Details

    • getValue

      public V getValue()
      Returns the wrapped value, or null if the representation used in this instance is not USE_VALUE;
      Returns:
      the wrapped value.
    • getRepresentation

      public ValueWrapper.Representation getRepresentation()
    • getExceptionMessage

      public String getExceptionMessage()
      Returns the message describing the invalidity of the key that maps to this instance.
      Returns:
      An exception message , possibly null.
    • toString

      public String toString()
      Overrides:
      toString in class Object