Interface Value

    • Method Detail

      • getValueType

        ValueType getValueType()
        Returns type of this value. Note that you can't use instanceof to check type of a value because type of a mutable value is variable.
      • immutableValue

        ImmutableValue immutableValue()
        Returns immutable copy of this value. This method simply returns this without copying the value if this value is already immutable.
      • isNilValue

        boolean isNilValue()
        Returns true if type of this value is Nil. If this method returns true, asNilValue never throws exceptions. Note that you can't use instanceof or cast ((NilValue) thisValue) to check type of a value because type of a mutable value is variable.
      • isBooleanValue

        boolean isBooleanValue()
        Returns true if type of this value is Boolean. If this method returns true, asBooleanValue never throws exceptions. Note that you can't use instanceof or cast ((BooleanValue) thisValue) to check type of a value because type of a mutable value is variable.
      • isNumberValue

        boolean isNumberValue()
        Returns true if type of this value is Integer or Float. If this method returns true, asNumberValue never throws exceptions. Note that you can't use instanceof or cast ((NumberValue) thisValue) to check type of a value because type of a mutable value is variable.
      • isIntegerValue

        boolean isIntegerValue()
        Returns true if type of this value is Integer. If this method returns true, asIntegerValue never throws exceptions. Note that you can't use instanceof or cast ((IntegerValue) thisValue) to check type of a value because type of a mutable value is variable.
      • isFloatValue

        boolean isFloatValue()
        Returns true if type of this value is Float. If this method returns true, asFloatValue never throws exceptions. Note that you can't use instanceof or cast ((FloatValue) thisValue) to check type of a value because type of a mutable value is variable.
      • isRawValue

        boolean isRawValue()
        Returns true if type of this value is String or Binary. If this method returns true, asRawValue never throws exceptions. Note that you can't use instanceof or cast ((RawValue) thisValue) to check type of a value because type of a mutable value is variable.
      • isBinaryValue

        boolean isBinaryValue()
        Returns true if type of this value is Binary. If this method returns true, asBinaryValue never throws exceptions. Note that you can't use instanceof or cast ((BinaryValue) thisValue) to check type of a value because type of a mutable value is variable.
      • isStringValue

        boolean isStringValue()
        Returns true if type of this value is String. If this method returns true, asStringValue never throws exceptions. Note that you can't use instanceof or cast ((StringValue) thisValue) to check type of a value because type of a mutable value is variable.
      • isArrayValue

        boolean isArrayValue()
        Returns true if type of this value is Array. If this method returns true, asArrayValue never throws exceptions. Note that you can't use instanceof or cast ((ArrayValue) thisValue) to check type of a value because type of a mutable value is variable.
      • isMapValue

        boolean isMapValue()
        Returns true if type of this value is Map. If this method returns true, asMapValue never throws exceptions. Note that you can't use instanceof or cast ((MapValue) thisValue) to check type of a value because type of a mutable value is variable.
      • isExtensionValue

        boolean isExtensionValue()
        Returns true if type of this an Extension. If this method returns true, asExtensionValue never throws exceptions. Note that you can't use instanceof or cast ((ExtensionValue) thisValue) to check type of a value because type of a mutable value is variable.
      • asNilValue

        NilValue asNilValue()
        Returns the value as NilValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((NilValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not Nil.
      • asBooleanValue

        BooleanValue asBooleanValue()
        Returns the value as BooleanValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((BooleanValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not Boolean.
      • asNumberValue

        NumberValue asNumberValue()
        Returns the value as NumberValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((NumberValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not Integer or Float.
      • asIntegerValue

        IntegerValue asIntegerValue()
        Returns the value as IntegerValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((IntegerValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not Integer.
      • asFloatValue

        FloatValue asFloatValue()
        Returns the value as FloatValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((FloatValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not Float.
      • asRawValue

        RawValue asRawValue()
        Returns the value as RawValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((RawValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not Binary or String.
      • asBinaryValue

        BinaryValue asBinaryValue()
        Returns the value as BinaryValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((BinaryValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not Binary.
      • asStringValue

        StringValue asStringValue()
        Returns the value as StringValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((StringValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not String.
      • asArrayValue

        ArrayValue asArrayValue()
        Returns the value as ArrayValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((ArrayValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not Array.
      • asMapValue

        MapValue asMapValue()
        Returns the value as MapValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((MapValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not Map.
      • asExtensionValue

        ExtensionValue asExtensionValue()
        Returns the value as ExtensionValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((ExtensionValue) thisValue) to check type of a value because type of a mutable value is variable.
        Throws:
        MessageTypeCastException - If type of this value is not an Extension.
      • writeTo

        void writeTo​(MessagePacker pk)
              throws java.io.IOException
        Serializes the value using the specified MessagePacker
        Throws:
        java.io.IOException
        See Also:
        MessagePacker
      • equals

        boolean equals​(java.lang.Object obj)
        Compares this value to the specified object. This method returns true if type and value are equivalent. If this value is MapValue or ArrayValue, this method check equivalence of elements recursively.
        Overrides:
        equals in class java.lang.Object
      • toJson

        java.lang.String toJson()
        Returns json representation of this Value.

        Following behavior is not configurable at this release and they might be changed at future releases:

        • if a key of MapValue is not string, the key is converted to a string using toString method.
        • NaN and Infinity of DoubleValue are converted to null.
        • ExtensionValue is converted to a 2-element array where first element is a number and second element is the data encoded in hex.
        • BinaryValue is converted to a string using UTF-8 encoding. Invalid byte sequence is replaced with U+FFFD replacement character.
        • Invalid UTF-8 byte sequences in StringValue is replaced with U+FFFD replacement character