Class RulePredicates

java.lang.Object
org.openhab.core.automation.RulePredicates

@NonNullByDefault public class RulePredicates extends Object
This class add support for prefixes for Rule UIDs and provide default predicates for prefixes and tags.
Author:
Victor Toni - Initial contribution
  • Field Details

    • PREFIX_SEPARATOR

      public static final String PREFIX_SEPARATOR
      Constant defining separator between prefix and UID.
      See Also:
  • Constructor Details

    • RulePredicates

      public RulePredicates()
  • Method Details

    • getPrefix

      public static @Nullable String getPrefix(@Nullable Rule rule)
      Gets the prefix of the Rule's UID, if any exist. The UID is either set automatically when the Rule is added or by the creating party. It's an optional property.

      Implementation note:
      The name space is part of the UID and the prefix thereof.
      If the UID does not contain a PREFIX_SEPARATOR null will be returned.
      If the UID does contain a PREFIX_SEPARATOR the prefix until the first occurrence will be returned.
      If the prefix would have a zero length null will be returned.
      Returns:
      prefix of this Rule, or null if no prefix or an empty prefix is found.
    • hasPrefix

      public static Predicate<Rule> hasPrefix(@Nullable String prefix)
      Creates a Predicate which can be used to filter Rules for a given prefix or null prefix.
      Parameters:
      prefix - to search for.
      Returns:
      created Predicate.
    • hasAnyOfPrefixes

      public static Predicate<Rule> hasAnyOfPrefixes(String... prefixes)
      Creates a Predicate which can be used to match Rules for any of the given prefixes and even null prefix.
      Parameters:
      prefixes - to search for.
      Returns:
      created Predicate.
    • hasTags

      public static Predicate<Rule> hasTags()
      Creates a Predicate which can be used to match Rules with one or more tags.
      Returns:
      created Predicate.
    • hasNoTags

      public static Predicate<Rule> hasNoTags()
      Creates a Predicate which can be used to match Rules without tags.
      Returns:
      created Predicate.
    • hasAllTags

      public static Predicate<Rule> hasAllTags(@Nullable Collection<String> tags)
      Creates a Predicate which can be used to match Rules with all given tags or no tags at all. All given tags must match, (the matched Rule might contain more).
      Parameters:
      tags - to search for.
      Returns:
      created Predicate.
    • hasAllTags

      public static Predicate<Rule> hasAllTags(String @Nullable ... tags)
      Creates a Predicate which can be used to match Rules for all given tags or no tags at all. All given tags must match, (the matched Rule might contain more).
      Parameters:
      tags - to search for.
      Returns:
      created Predicate.
    • hasAnyOfTags

      public static Predicate<Rule> hasAnyOfTags(@Nullable Collection<String> tags)
      Creates a Predicate which can be used to match Rules for any of the given tags or Rules without tags.
      Parameters:
      tags - to search for.
      Returns:
      created Predicate.
    • hasAnyOfTags

      public static Predicate<Rule> hasAnyOfTags(String @Nullable ... tags)
      Creates a Predicate which can be used to match Rules for any of the given tags or Rules without tags.
      Parameters:
      tags - to search for.
      Returns:
      created Predicate.