Package org.openhab.core.automation
Class RulePredicates
java.lang.Object
org.openhab.core.automation.RulePredicates
This class add support for prefixes for
Rule UIDs and provide default predicates for prefixes and tags.- Author:
- Victor Toni - Initial contribution
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstant defining separator between prefix and UID. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable StringGets the prefix of theRule's UID, if any exist.hasAllTags(String @Nullable ... tags) hasAllTags(@Nullable Collection<String> tags) hasAnyOfPrefixes(String... prefixes) hasAnyOfTags(String @Nullable ... tags) hasAnyOfTags(@Nullable Collection<String> tags) hasTags()
-
Field Details
-
PREFIX_SEPARATOR
Constant defining separator between prefix and UID.- See Also:
-
-
Constructor Details
-
RulePredicates
public RulePredicates()
-
-
Method Details
-
getPrefix
Gets the prefix of theRule's UID, if any exist. The UID is either set automatically when theRuleis 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 aPREFIX_SEPARATORnullwill be returned.
If the UID does contain aPREFIX_SEPARATORthe prefix until the first occurrence will be returned.
If the prefix would have a zero lengthnullwill be returned.- Returns:
- prefix of this
Rule, ornullif no prefix or an empty prefix is found.
-
hasPrefix
- Parameters:
prefix- to search for.- Returns:
- created
Predicate.
-
hasAnyOfPrefixes
Creates aPredicatewhich can be used to matchRules for any of the given prefixes and evennullprefix.- Parameters:
prefixes- to search for.- Returns:
- created
Predicate.
-
hasTags
- Returns:
- created
Predicate.
-
hasNoTags
- Returns:
- created
Predicate.
-
hasAllTags
Creates aPredicatewhich can be used to matchRules with all given tags or no tags at all. All given tags must match, (the matchedRulemight contain more).- Parameters:
tags- to search for.- Returns:
- created
Predicate.
-
hasAllTags
Creates aPredicatewhich can be used to matchRules for all given tags or no tags at all. All given tags must match, (the matchedRulemight contain more).- Parameters:
tags- to search for.- Returns:
- created
Predicate.
-
hasAnyOfTags
Creates aPredicatewhich can be used to matchRules for any of the given tags orRules without tags.- Parameters:
tags- to search for.- Returns:
- created
Predicate.
-
hasAnyOfTags
Creates aPredicatewhich can be used to matchRules for any of the given tags orRules without tags.- Parameters:
tags- to search for.- Returns:
- created
Predicate.
-