Class ChannelTransformation

java.lang.Object
org.openhab.core.thing.binding.generic.ChannelTransformation

@NonNullByDefault public class ChannelTransformation extends Object
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 Details

    • ChannelTransformation

      public ChannelTransformation(@Nullable String transformationString)
    • ChannelTransformation

      public ChannelTransformation(@Nullable List<String> transformationStrings)
  • 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

      public Optional<String> apply(String value)
      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

      public static boolean isValidTransformation(@Nullable String value)
      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.