Package org.msgpack.value.impl
Class ImmutableBooleanValueImpl
- java.lang.Object
-
- org.msgpack.value.impl.ImmutableBooleanValueImpl
-
- All Implemented Interfaces:
BooleanValue
,ImmutableBooleanValue
,ImmutableValue
,Value
public class ImmutableBooleanValueImpl extends java.lang.Object implements ImmutableBooleanValue
ImmutableBooleanValueImpl
ImplementsImmutableBooleanValue
using aboolean
field. This class is a singleton.ImmutableBooleanValueImpl.trueInstance()
andImmutableBooleanValueImpl.falseInstance()
are the only instances of this class.- See Also:
BooleanValue
-
-
Field Summary
Fields Modifier and Type Field Description static ImmutableBooleanValue
FALSE
static ImmutableBooleanValue
TRUE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableArrayValue
asArrayValue()
Returns the value asArrayValue
.ImmutableBinaryValue
asBinaryValue()
Returns the value asBinaryValue
.ImmutableBooleanValue
asBooleanValue()
Returns the value asBooleanValue
.ImmutableExtensionValue
asExtensionValue()
Returns the value asExtensionValue
.ImmutableFloatValue
asFloatValue()
Returns the value asFloatValue
.ImmutableIntegerValue
asIntegerValue()
Returns the value asIntegerValue
.ImmutableMapValue
asMapValue()
Returns the value asMapValue
.ImmutableNilValue
asNilValue()
Returns the value asNilValue
.ImmutableNumberValue
asNumberValue()
Returns the value asNumberValue
.ImmutableRawValue
asRawValue()
Returns the value asRawValue
.ImmutableStringValue
asStringValue()
Returns the value asStringValue
.boolean
equals(java.lang.Object o)
Compares this value to the specified object.boolean
getBoolean()
Returns the value as aboolean
.ValueType
getValueType()
Returns type of this value.int
hashCode()
ImmutableBooleanValue
immutableValue()
Returns immutable copy of this value.boolean
isArrayValue()
Returns true if type of this value is Array.boolean
isBinaryValue()
Returns true if type of this value is Binary.boolean
isBooleanValue()
Returns true if type of this value is Boolean.boolean
isExtensionValue()
Returns true if type of this an Extension.boolean
isFloatValue()
Returns true if type of this value is Float.boolean
isIntegerValue()
Returns true if type of this value is Integer.boolean
isMapValue()
Returns true if type of this value is Map.boolean
isNilValue()
Returns true if type of this value is Nil.boolean
isNumberValue()
Returns true if type of this value is Integer or Float.boolean
isRawValue()
Returns true if type of this value is String or Binary.boolean
isStringValue()
Returns true if type of this value is String.java.lang.String
toJson()
Returns json representation of this Value.java.lang.String
toString()
void
writeTo(MessagePacker packer)
Serializes the value using the specifiedMessagePacker
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.msgpack.value.ImmutableValue
asArrayValue, asBinaryValue, asFloatValue, asIntegerValue, asMapValue, asNilValue, asRawValue, asStringValue
-
Methods inherited from interface org.msgpack.value.Value
asExtensionValue, asNumberValue, isArrayValue, isBinaryValue, isBooleanValue, isExtensionValue, isFloatValue, isIntegerValue, isMapValue, isNilValue, isNumberValue, isRawValue, isStringValue
-
-
-
-
Field Detail
-
TRUE
public static final ImmutableBooleanValue TRUE
-
FALSE
public static final ImmutableBooleanValue FALSE
-
-
Method Detail
-
getValueType
public ValueType getValueType()
Description copied from interface:Value
Returns type of this value. Note that you can't useinstanceof
to check type of a value because type of a mutable value is variable.- Specified by:
getValueType
in interfaceValue
-
asBooleanValue
public ImmutableBooleanValue asBooleanValue()
Description copied from interface:Value
Returns the value asBooleanValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((BooleanValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asBooleanValue
in interfaceImmutableValue
- Specified by:
asBooleanValue
in interfaceValue
-
immutableValue
public ImmutableBooleanValue immutableValue()
Description copied from interface:Value
Returns immutable copy of this value. This method simply returnsthis
without copying the value if this value is already immutable.- Specified by:
immutableValue
in interfaceValue
-
getBoolean
public boolean getBoolean()
Description copied from interface:BooleanValue
Returns the value as aboolean
.- Specified by:
getBoolean
in interfaceBooleanValue
-
writeTo
public void writeTo(MessagePacker packer) throws java.io.IOException
Description copied from interface:Value
Serializes the value using the specifiedMessagePacker
- Specified by:
writeTo
in interfaceValue
- Throws:
java.io.IOException
- See Also:
MessagePacker
-
equals
public boolean equals(java.lang.Object o)
Description copied from interface:Value
Compares this value to the specified object. This method returnstrue
if type and value are equivalent. If this value isMapValue
orArrayValue
, this method check equivalence of elements recursively.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toJson
public java.lang.String toJson()
Description copied from interface:Value
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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isNilValue
public boolean isNilValue()
Description copied from interface:Value
Returns true if type of this value is Nil. If this method returns true,asNilValue
never throws exceptions. Note that you can't useinstanceof
or cast((NilValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isNilValue
in interfaceValue
-
isBooleanValue
public boolean isBooleanValue()
Description copied from interface:Value
Returns true if type of this value is Boolean. If this method returns true,asBooleanValue
never throws exceptions. Note that you can't useinstanceof
or cast((BooleanValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isBooleanValue
in interfaceValue
-
isNumberValue
public boolean isNumberValue()
Description copied from interface:Value
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 useinstanceof
or cast((NumberValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isNumberValue
in interfaceValue
-
isIntegerValue
public boolean isIntegerValue()
Description copied from interface:Value
Returns true if type of this value is Integer. If this method returns true,asIntegerValue
never throws exceptions. Note that you can't useinstanceof
or cast((IntegerValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isIntegerValue
in interfaceValue
-
isFloatValue
public boolean isFloatValue()
Description copied from interface:Value
Returns true if type of this value is Float. If this method returns true,asFloatValue
never throws exceptions. Note that you can't useinstanceof
or cast((FloatValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isFloatValue
in interfaceValue
-
isRawValue
public boolean isRawValue()
Description copied from interface:Value
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 useinstanceof
or cast((RawValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isRawValue
in interfaceValue
-
isBinaryValue
public boolean isBinaryValue()
Description copied from interface:Value
Returns true if type of this value is Binary. If this method returns true,asBinaryValue
never throws exceptions. Note that you can't useinstanceof
or cast((BinaryValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isBinaryValue
in interfaceValue
-
isStringValue
public boolean isStringValue()
Description copied from interface:Value
Returns true if type of this value is String. If this method returns true,asStringValue
never throws exceptions. Note that you can't useinstanceof
or cast((StringValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isStringValue
in interfaceValue
-
isArrayValue
public boolean isArrayValue()
Description copied from interface:Value
Returns true if type of this value is Array. If this method returns true,asArrayValue
never throws exceptions. Note that you can't useinstanceof
or cast((ArrayValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isArrayValue
in interfaceValue
-
isMapValue
public boolean isMapValue()
Description copied from interface:Value
Returns true if type of this value is Map. If this method returns true,asMapValue
never throws exceptions. Note that you can't useinstanceof
or cast((MapValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isMapValue
in interfaceValue
-
isExtensionValue
public boolean isExtensionValue()
Description copied from interface:Value
Returns true if type of this an Extension. If this method returns true,asExtensionValue
never throws exceptions. Note that you can't useinstanceof
or cast((ExtensionValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isExtensionValue
in interfaceValue
-
asNilValue
public ImmutableNilValue asNilValue()
Description copied from interface:Value
Returns the value asNilValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((NilValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asNilValue
in interfaceImmutableValue
- Specified by:
asNilValue
in interfaceValue
-
asNumberValue
public ImmutableNumberValue asNumberValue()
Description copied from interface:Value
Returns the value asNumberValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((NumberValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asNumberValue
in interfaceValue
-
asIntegerValue
public ImmutableIntegerValue asIntegerValue()
Description copied from interface:Value
Returns the value asIntegerValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((IntegerValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asIntegerValue
in interfaceImmutableValue
- Specified by:
asIntegerValue
in interfaceValue
-
asFloatValue
public ImmutableFloatValue asFloatValue()
Description copied from interface:Value
Returns the value asFloatValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((FloatValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asFloatValue
in interfaceImmutableValue
- Specified by:
asFloatValue
in interfaceValue
-
asRawValue
public ImmutableRawValue asRawValue()
Description copied from interface:Value
Returns the value asRawValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((RawValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asRawValue
in interfaceImmutableValue
- Specified by:
asRawValue
in interfaceValue
-
asBinaryValue
public ImmutableBinaryValue asBinaryValue()
Description copied from interface:Value
Returns the value asBinaryValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((BinaryValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asBinaryValue
in interfaceImmutableValue
- Specified by:
asBinaryValue
in interfaceValue
-
asStringValue
public ImmutableStringValue asStringValue()
Description copied from interface:Value
Returns the value asStringValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((StringValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asStringValue
in interfaceImmutableValue
- Specified by:
asStringValue
in interfaceValue
-
asArrayValue
public ImmutableArrayValue asArrayValue()
Description copied from interface:Value
Returns the value asArrayValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((ArrayValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asArrayValue
in interfaceImmutableValue
- Specified by:
asArrayValue
in interfaceValue
-
asMapValue
public ImmutableMapValue asMapValue()
Description copied from interface:Value
Returns the value asMapValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((MapValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asMapValue
in interfaceImmutableValue
- Specified by:
asMapValue
in interfaceValue
-
asExtensionValue
public ImmutableExtensionValue asExtensionValue()
Description copied from interface:Value
Returns the value asExtensionValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((ExtensionValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asExtensionValue
in interfaceValue
-
-