Class Value

java.lang.Object
dev.openfeature.sdk.Value
All Implemented Interfaces:
Cloneable

public class Value extends Object implements Cloneable
Values serve as a generic return type for structure data from providers. Providers may deal in JSON, protobuf, XML or some other data-interchange format. This intermediate representation provides a good medium of exchange.
  • Constructor Details

    • Value

      public Value()
      Construct a new null Value.
    • Value

      public Value(Object value) throws InstantiationException
      Construct a new Value with an Object.
      Parameters:
      value - to be wrapped.
      Throws:
      InstantiationException - if value is not a valid type (boolean, string, int, double, list, structure, instant)
    • Value

      public Value(Value value)
    • Value

      public Value(Boolean value)
    • Value

      public Value(String value)
    • Value

      public Value(Integer value)
    • Value

      public Value(Double value)
    • Value

      public Value(Structure value)
    • Value

      public Value(List<Value> value)
    • Value

      public Value(Instant value)
  • Method Details

    • finalize

      protected final void finalize()
      Overrides:
      finalize in class Object
    • isNull

      public boolean isNull()
      Check if this Value represents null.
      Returns:
      boolean
    • isBoolean

      public boolean isBoolean()
      Check if this Value represents a Boolean.
      Returns:
      boolean
    • isString

      public boolean isString()
      Check if this Value represents a String.
      Returns:
      boolean
    • isNumber

      public boolean isNumber()
      Check if this Value represents a numeric value.
      Returns:
      boolean
    • isStructure

      public boolean isStructure()
      Check if this Value represents a Structure.
      Returns:
      boolean
    • isList

      public boolean isList()
      Check if this Value represents a List of Values.
      Returns:
      boolean
    • isInstant

      public boolean isInstant()
      Check if this Value represents an Instant.
      Returns:
      boolean
    • asBoolean

      public Boolean asBoolean()
      Retrieve the underlying Boolean value, or null.
      Returns:
      Boolean
    • asObject

      public Object asObject()
      Retrieve the underlying object.
      Returns:
      Object
    • asString

      public String asString()
      Retrieve the underlying String value, or null.
      Returns:
      String
    • asInteger

      public Integer asInteger()
      Retrieve the underlying numeric value as an Integer, or null. If the value is not an integer, it will be rounded using Math.round().
      Returns:
      Integer
    • asDouble

      public Double asDouble()
      Retrieve the underlying numeric value as a Double, or null.
      Returns:
      Double
    • asStructure

      public Structure asStructure()
      Retrieve the underlying Structure value, or null.
      Returns:
      Structure
    • asList

      public List<Value> asList()
      Retrieve the underlying List value, or null.
      Returns:
      List
    • asInstant

      public Instant asInstant()
      Retrieve the underlying Instant value, or null.
      Returns:
      Instant
    • clone

      protected Value clone()
      Perform deep clone of value object.
      Overrides:
      clone in class Object
      Returns:
      Value
    • objectToValue

      public static Value objectToValue(Object object)
      Wrap an object into a Value.
      Parameters:
      object - the object to wrap
      Returns:
      the wrapped object