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
ConstructorDescriptionChannelTransformation
(@Nullable String transformationString) ChannelTransformation
(@Nullable List<String> transformationStrings) -
Method Summary
Modifier and TypeMethodDescriptionApplies all transformations to the given value.boolean
isEmpty()
Checks whether this object contains no transformation steps.boolean
Checks whether this object contains at least one transformation step.static boolean
isValidTransformation
(@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:
true
if the transformation is empty,false
otherwise.
-
isPresent
public boolean isPresent()Checks whether this object contains at least one transformation step.- Returns:
true
if the transformation is present,false
otherwise.
-
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:
true
if the string contains valid transformations,false
otherwise.
-