Class Value

java.lang.Object
com.tangosol.config.expression.Value

public final class Value extends Object
A Value is an immutable object that represents a value whose type is unknown at compile time. That is, the type of the value will only be known at runtime when it's requested.

Much like a Variant (wikipedia) a Value permits runtime coercion into other types, as and when required.

Since:
Coherence 12.1.2
Author:
bo 2011.06.05
  • Constructor Details

    • Value

      public Value()
      Construct a null Value.
    • Value

      public Value(Object oValue)
      Construct an Object-based Value.
      Parameters:
      oValue - the value of the Value instance
    • Value

      public Value(String sValue)
      Construct a String-based Value.

      Note: The provided String is trimmed for leading and trailing white-space.

      Parameters:
      sValue - the value of the Value instance
    • Value

      public Value(Value value)
      Construct a Value-based on another Value.
      Parameters:
      value - the value for the resulting Value instance
    • Value

      public Value(XmlValue value)
      Construct a Value based on the string content of an XmlValue.

      Note:

      • The XmlValue content is used and not the xml itself.
      • The content will be trimmed for leading and trailing white-space.
      Parameters:
      value - the value of the Value instance
  • Method Details

    • isNull

      public boolean isNull()
      Determines if the Value represents a null value.
      Returns:
      true if the value of the Value is null, otherwise false
    • get

      public Object get()
      Obtains the underlying Object representation of the Value.
      Returns:
      The Object representation of the Value (may be null)
    • supports

      public boolean supports(Class<?> clzType)
      Determines if the Value supports conversion/coercion to the specified type.

      NOTE: This does not test whether the Value can be coerced without an exception.

      Parameters:
      clzType - the type to which the Value should be coerced
      Returns:
      true if type is coercable, false otherwise
    • as

      Attempts to return the value of the Value coerced to a specified type.
      Type Parameters:
      T - the expected type of the value
      Parameters:
      clzType - the expected type of the value (the value to coerce to)
      Returns:
      the Value coerced in the required type
      Throws:
      ClassCastException - If the value of the Value can't be coerced to the specified type
      NumberFormatException - If the value of the Value can't be coerced to the specified type
      UnknownFormatConversionException - If the value of the Value can't be coerced to the specified type
    • toString

      public String toString()
      Overrides:
      toString in class Object