Class ChannelTransformation
java.lang.Object
org.openhab.core.thing.binding.generic.ChannelTransformation
The
ChannelTransformation can be used to transform an input value using one or more transformations.
Individual transformations can be chained with ∩ and must follow the pattern
serviceName:function where serviceName refers to a TransformationService and
function has to be a valid transformation function for this service- Author:
- Jan N. Klug - Initial contribution
-
Constructor Summary
ConstructorsConstructorDescriptionChannelTransformation(@Nullable String transformationString) ChannelTransformation(@Nullable List<String> transformationStrings) -
Method Summary
Modifier and TypeMethodDescriptionApplies all transformations to the given value.booleanisEmpty()Checks whether this object contains no transformation steps.booleanChecks whether this object contains at least one transformation step.static booleanisValidTransformation(@Nullable String value) Checks whether the given string contains valid transformations.
-
Constructor Details
-
ChannelTransformation
-
ChannelTransformation
-
-
Method Details
-
isEmpty
public boolean isEmpty()Checks whether this object contains no transformation steps.- Returns:
trueif the transformation is empty,falseotherwise.
-
isPresent
public boolean isPresent()Checks whether this object contains at least one transformation step.- Returns:
trueif the transformation is present,falseotherwise.
-
apply
Applies all transformations to the given value.- Parameters:
value- the value to transform.- Returns:
- the transformed value or an empty optional if the transformation failed. If the transformation is empty, the original value is returned.
-
isValidTransformation
Checks whether the given string contains valid transformations. Valid single and chained transformations will return true.- Parameters:
value- the transformation string to check.- Returns:
trueif the string contains valid transformations,falseotherwise.
-