Package io.openems.common.types
Class ConfigurationProperty<T>
java.lang.Object
io.openems.common.types.ConfigurationProperty<T>
- Type Parameters:
T
- type of the configuration property
Holds the value of a configuration property.
This implementation is similar to Optional<>, but it makes a difference if a value is 'null' - i.e. configuration property should be set to 'null' - or 'not set' - i.e. configuration property should not be changed.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ConfigurationProperty<T>
asNotSet()
Creates aConfigurationProperty
object with 'not set' value.static <T> ConfigurationProperty<T>
asNull()
Creates aConfigurationProperty
object with 'null' value.static <T> ConfigurationProperty<T>
fromJsonElement
(Optional<com.google.gson.JsonElement> element, ThrowingFunction<com.google.gson.JsonElement, T, OpenemsError.OpenemsNamedException> function) Creates aConfigurationProperty
object from aJsonElement
value.getValue()
boolean
isNull()
boolean
isSet()
boolean
static <T> ConfigurationProperty<T>
of
(T value) Creates aConfigurationProperty
object from a value.
-
Method Details
-
of
Creates aConfigurationProperty
object from a value.- Type Parameters:
T
- the type of the value- Parameters:
value
- the value- Returns:
- the
ConfigurationProperty
-
asNull
Creates aConfigurationProperty
object with 'null' value.- Type Parameters:
T
- the type of the value- Returns:
- the
ConfigurationProperty
-
asNotSet
Creates aConfigurationProperty
object with 'not set' value.- Type Parameters:
T
- the type of the value- Returns:
- the
ConfigurationProperty
-
fromJsonElement
public static <T> ConfigurationProperty<T> fromJsonElement(Optional<com.google.gson.JsonElement> element, ThrowingFunction<com.google.gson.JsonElement, T, throws OpenemsError.OpenemsNamedExceptionOpenemsError.OpenemsNamedException> function) Creates aConfigurationProperty
object from aJsonElement
value.- Type Parameters:
T
- the type of the value- Parameters:
element
- theJsonElement
valuefunction
- conversion function fromJsonElement
to type T- Returns:
- the
ConfigurationProperty
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getValue
-
isNull
public boolean isNull() -
isSet
public boolean isSet() -
isSetAndNotNull
public boolean isSetAndNotNull()
-