T
- the type of the valuepublic class Value<T>
extends java.lang.Object
To get the actual value of a Channel using this object, typically one of the following methods will fit:
get()
: gets the value or null. Be aware of
NullPointerException
s!
getOrError()
: gets the value or throws an
InvalidValueException
if the value is null
orElse(Object)
: gets the value; or fallback alternative if the
value is null
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
UNDEFINED_VALUE_STRING |
Modifier and Type | Method and Description |
---|---|
<O extends OptionsEnum> |
asEnum()
Gets the value as its Enum option.
|
com.google.gson.JsonElement |
asJson()
Gets the value in GSON JSON format
|
java.util.Optional<T> |
asOptional()
Gets the value as an Optional.
|
java.lang.String |
asOptionString()
Gets the value as its String option.
|
java.lang.String |
asString()
Gets the value as a formatted String with its unit.
|
java.lang.String |
asStringWithoutUnit()
Gets the value as a formatted String without its unit
|
T |
get()
Gets the value or null
|
T |
getOrError()
Gets the value or throws an Exception on null
|
java.time.LocalDateTime |
getTimestamp()
Gets the timestamp when the value was created.
|
boolean |
isDefined()
Is the value defined?.
|
T |
orElse(T alternativeValue)
Gets the value or the given alternativeValue.
|
java.lang.String |
toString() |
public static final java.lang.String UNDEFINED_VALUE_STRING
public java.lang.String asString()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String asStringWithoutUnit()
public T get()
public T getOrError() throws InvalidValueException
InvalidValueException
public java.util.Optional<T> asOptional()
public boolean isDefined()
public T orElse(T alternativeValue)
public java.lang.String asOptionString()
java.lang.IllegalArgumentException
- no matching option existingpublic <O extends OptionsEnum> O asEnum()
java.lang.IllegalArgumentException
- no matching Enum option existingpublic com.google.gson.JsonElement asJson()
public java.time.LocalDateTime getTimestamp()