Package io.ably.lib.liveobjects.value
Class LiveMapValue
java.lang.Object
io.ably.lib.liveobjects.value.LiveMapValue
The union of values assignable to a
LiveMap key:
Boolean | Binary | Number | String | JsonArray | JsonObject |
LiveCounter | LiveMap. Provides compile-time type safety for write
operations; the design follows Gson's JsonElement pattern.
The LiveMap and LiveCounter variants hold new-object
value types describing the initial state of a nested object to create -
not references to existing live objects.
Spec: RTPO15a2 / RTINS12a2 / RTLM20 (accepted value types)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte @NotNull []Gets the Binary value if this LiveMapValue represents a Binary.@NotNull BooleanGets the Boolean value if this LiveMapValue represents a Boolean.@NotNull com.google.gson.JsonArrayGets the JsonArray value if this LiveMapValue represents a JsonArray.@NotNull com.google.gson.JsonObjectGets the JsonObject value if this LiveMapValue represents a JsonObject.@NotNull LiveCounterGets theLiveCountervalue type if this LiveMapValue represents one.@NotNull LiveMapGets theLiveMapvalue type if this LiveMapValue represents one.@NotNull NumberGets the Number value if this LiveMapValue represents a Number.@NotNull StringGets the String value if this LiveMapValue represents a String.abstract @NotNull ObjectgetValue()Gets the underlying value.booleanisBinary()Returns true if this LiveMapValue represents a Binary value.booleanReturns true if this LiveMapValue represents a Boolean value.booleanReturns true if this LiveMapValue represents a JsonArray value.booleanReturns true if this LiveMapValue represents a JsonObject value.booleanReturns true if this LiveMapValue represents a newLiveCountervalue type.booleanReturns true if this LiveMapValue represents a newLiveMapvalue type.booleanisNumber()Returns true if this LiveMapValue represents a Number value.booleanisString()Returns true if this LiveMapValue represents a String value.static @NotNull LiveMapValueof(byte @NotNull [] value) Creates a LiveMapValue from a Binary.static @NotNull LiveMapValueof(@NotNull com.google.gson.JsonArray value) Creates a LiveMapValue from a JsonArray.static @NotNull LiveMapValueof(@NotNull com.google.gson.JsonObject value) Creates a LiveMapValue from a JsonObject.static @NotNull LiveMapValueof(@NotNull LiveCounter value) Creates a LiveMapValue from a newLiveCountervalue type.static @NotNull LiveMapValueCreates a LiveMapValue from a newLiveMapvalue type.static @NotNull LiveMapValueCreates a LiveMapValue from a Boolean.static @NotNull LiveMapValueCreates a LiveMapValue from a Number.static @NotNull LiveMapValueCreates a LiveMapValue from a String.
-
Constructor Details
-
LiveMapValue
public LiveMapValue()
-
-
Method Details
-
getValue
Gets the underlying value.- Returns:
- the value as an Object
-
isBoolean
public boolean isBoolean()Returns true if this LiveMapValue represents a Boolean value.- Returns:
- true if this is a Boolean value
-
isBinary
public boolean isBinary()Returns true if this LiveMapValue represents a Binary value.- Returns:
- true if this is a Binary value
-
isNumber
public boolean isNumber()Returns true if this LiveMapValue represents a Number value.- Returns:
- true if this is a Number value
-
isString
public boolean isString()Returns true if this LiveMapValue represents a String value.- Returns:
- true if this is a String value
-
isJsonArray
public boolean isJsonArray()Returns true if this LiveMapValue represents a JsonArray value.- Returns:
- true if this is a JsonArray value
-
isJsonObject
public boolean isJsonObject()Returns true if this LiveMapValue represents a JsonObject value.- Returns:
- true if this is a JsonObject value
-
isLiveCounter
public boolean isLiveCounter()Returns true if this LiveMapValue represents a newLiveCountervalue type.- Returns:
- true if this is a LiveCounter value
-
isLiveMap
public boolean isLiveMap()Returns true if this LiveMapValue represents a newLiveMapvalue type.- Returns:
- true if this is a LiveMap value
-
getAsBoolean
Gets the Boolean value if this LiveMapValue represents a Boolean.- Returns:
- the Boolean value
- Throws:
-
IllegalStateException- if this is not a Boolean value
-
getAsBinary
public byte @NotNull [] getAsBinary()Gets the Binary value if this LiveMapValue represents a Binary.- Returns:
- the Binary value
- Throws:
-
IllegalStateException- if this is not a Binary value
-
getAsNumber
Gets the Number value if this LiveMapValue represents a Number.- Returns:
- the Number value
- Throws:
-
IllegalStateException- if this is not a Number value
-
getAsString
Gets the String value if this LiveMapValue represents a String.- Returns:
- the String value
- Throws:
-
IllegalStateException- if this is not a String value
-
getAsJsonArray
@NotNull public @NotNull com.google.gson.JsonArray getAsJsonArray()Gets the JsonArray value if this LiveMapValue represents a JsonArray.- Returns:
- the JsonArray value
- Throws:
-
IllegalStateException- if this is not a JsonArray value
-
getAsJsonObject
@NotNull public @NotNull com.google.gson.JsonObject getAsJsonObject()Gets the JsonObject value if this LiveMapValue represents a JsonObject.- Returns:
- the JsonObject value
- Throws:
-
IllegalStateException- if this is not a JsonObject value
-
getAsLiveCounter
Gets theLiveCountervalue type if this LiveMapValue represents one.- Returns:
- the LiveCounter value type
- Throws:
-
IllegalStateException- if this is not a LiveCounter value
-
getAsLiveMap
Gets theLiveMapvalue type if this LiveMapValue represents one.- Returns:
- the LiveMap value type
- Throws:
-
IllegalStateException- if this is not a LiveMap value
-
of
Creates a LiveMapValue from a Boolean.- Parameters:
-
value- the boolean value - Returns:
- a LiveMapValue containing the boolean
-
of
Creates a LiveMapValue from a Binary. The array is copied, so later modifications tovaluedo not affect the created LiveMapValue.- Parameters:
-
value- the binary value - Returns:
- a LiveMapValue containing the binary
-
of
Creates a LiveMapValue from a Number.- Parameters:
-
value- the number value - Returns:
- a LiveMapValue containing the number
-
of
Creates a LiveMapValue from a String.- Parameters:
-
value- the string value - Returns:
- a LiveMapValue containing the string
-
of
Creates a LiveMapValue from a JsonArray.- Parameters:
-
value- the JsonArray value - Returns:
- a LiveMapValue containing the JsonArray
-
of
Creates a LiveMapValue from a JsonObject.- Parameters:
-
value- the JsonObject value - Returns:
- a LiveMapValue containing the JsonObject
-
of
Creates a LiveMapValue from a newLiveCountervalue type.- Parameters:
-
value- the LiveCounter value type - Returns:
- a LiveMapValue containing the LiveCounter
-
of
Creates a LiveMapValue from a newLiveMapvalue type.- Parameters:
-
value- the LiveMap value type - Returns:
- a LiveMapValue containing the LiveMap
-