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 <[email protected]>
  • Loading branch information
clinique authored Oct 9, 2023
1 parent 30b0e46 commit 867e27a
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 @@ -27,6 +27,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -78,6 +79,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 @@ -121,6 +124,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 867e27a

Please sign in to comment.