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
Modifier and TypeFieldDescriptionstatic final String
Constant defining separator between prefix and UID. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable String
Gets the prefix of theRule
's UID, if any exist.hasAllTags
(@Nullable Collection<String> tags) hasAllTags
(String @Nullable ... tags) hasAnyOfPrefixes
(String... prefixes) hasAnyOfTags
(@Nullable Collection<String> tags) hasAnyOfTags
(String @Nullable ... 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 theRule
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 aPREFIX_SEPARATOR
null
will be returned.
If the UID does contain aPREFIX_SEPARATOR
the prefix until the first occurrence will be returned.
If the prefix would have a zero lengthnull
will be returned.- Returns:
- prefix of this
Rule
, ornull
if no prefix or an empty prefix is found.
-
hasPrefix
- Parameters:
prefix
- to search for.- Returns:
- created
Predicate
.
-
hasAnyOfPrefixes
Creates aPredicate
which can be used to matchRule
s for any of the given prefixes and evennull
prefix.- Parameters:
prefixes
- to search for.- Returns:
- created
Predicate
.
-
hasTags
- Returns:
- created
Predicate
.
-
hasNoTags
- Returns:
- created
Predicate
.
-
hasAllTags
Creates aPredicate
which can be used to matchRule
s with all given tags or no tags at all. All given tags must match, (the matchedRule
might contain more).- Parameters:
tags
- to search for.- Returns:
- created
Predicate
.
-
hasAllTags
Creates aPredicate
which can be used to matchRule
s for all given tags or no tags at all. All given tags must match, (the matchedRule
might contain more).- Parameters:
tags
- to search for.- Returns:
- created
Predicate
.
-
hasAnyOfTags
Creates aPredicate
which can be used to matchRule
s for any of the given tags orRule
s without tags.- Parameters:
tags
- to search for.- Returns:
- created
Predicate
.
-
hasAnyOfTags
Creates aPredicate
which can be used to matchRule
s for any of the given tags orRule
s without tags.- Parameters:
tags
- to search for.- Returns:
- created
Predicate
.
-