Skip to content

Commit

Permalink
[javarule] Adding tags to Rule annotation (#525)
Browse files Browse the repository at this point in the history
* [javarule] Adding tags to Rule annotation
Adresses issue #504

Signed-off-by: clinique <gael@lhopital.org>
(cherry picked from commit 867e27a)
Signed-off-by: Jan N. Klug <github@klug.nrw>

# Conflicts:
#	bundles/org.smarthomej.automation.javarule/src/main/java/org/smarthomej/automation/javarule/internal/script/RuleProcessor.java
  • Loading branch information
J-N-K committed Oct 9, 2023
1 parent 72702e4 commit 3140ab2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
public @interface Rule {
String name() default ANNOTATION_DEFAULT;

String[] tags() default {};

boolean disabled() default false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -77,6 +78,8 @@ public static List<SimpleRule> getSimpleRules(String scriptIdentifier, JavaRule

String ruleName = method.getName();
String ruleDescription = ruleAnnotation.name();
Set<String> ruleTags = Set.of(ruleAnnotation.tags());

if (ruleDescription.isBlank() || ANNOTATION_DEFAULT.equals(ruleDescription)) {
ruleDescription = script.getClass().getSimpleName() + "/" + method.getName();
}
Expand Down Expand Up @@ -119,6 +122,7 @@ public Object execute(Action module, Map<String, ?> input) {
simpleRule.setDescription(ruleDescription);
simpleRule.setTriggers(triggers);
simpleRule.setConditions(conditions);
simpleRule.setTags(ruleTags);

rules.add(simpleRule);

Expand Down

0 comments on commit 3140ab2

Please sign in to comment.