/** * @author Alexander Wert * */ @Rule public interface AnnotatedInterface { }
/** * Utility method to create a {@link FireCondition} either from a {@link Rule} annotation or * from {@link TagInjection}s. The values defined in the annotation overrules the * {@link TagInjection}s. * * @param rule * The {@link Rule} annotation. * @param tagInjections * The list of {@link TagInjection}s to extract a {@link FireCondition}. * @return A new {@link FireCondition} */ public static FireCondition describeFireCondition(Rule rule, List<TagInjection> tagInjections) { if ((rule != null) && ArrayUtils.isNotEmpty(rule.fireCondition())) { return new FireCondition(Sets.newHashSet(Arrays.asList(rule.fireCondition()))); } else { Set<String> requiredTypes = new HashSet<>(); for (TagInjection injection : tagInjections) { requiredTypes.add(injection.getType()); } return new FireCondition(requiredTypes); } }
builder.setName(annotation.name()); builder.setDescription(annotation.description()); builder.setImplementation(clazz); builder.setFireCondition(fireCondition);
@Rule(name = "ProblemCauseRule") public class ProblemCauseRule {
/** * @author Alexander Wert * */ @Rule(name = "RuleA", description = "RuleADescription") public class RuleA { @TagValue(type = Tags.ROOT_TAG) String input; @Action(resultTag = "A") public String action() { return input + input; } }
/** * @author Alexander Wert * */ @Rule(name = "RuleA", description = "RuleADescription") public class RuleA { @TagValue(type = Tags.ROOT_TAG) String input; @Action(resultTag = "A") public String action() { return input + input; } }
/** * @author Alexander Wert * */ @Rule(name = "RuleB") public class RuleB { @TagValue(type = "A") String input; @Action(resultTag = "B") public int action() { return input.length(); } }
/** * @author Alexander Wert * */ @Rule(name = "RuleB") public class RuleB { @TagValue(type = "A") String input; @Action(resultTag = "B") public int action() { return input.length(); } }
/** * @author Alexander Wert * */ @Rule(name = "RuleE") public class RuleE { @TagValue(type = Tags.ROOT_TAG) String input; @Action(resultTag = "E") public String action() { return input + "E"; } }
/** * @author Alexander Wert * */ @Rule(name = "RuleD") public class RuleD { @TagValue(type = Tags.ROOT_TAG) String input; @Action(resultTag = "D") public int action() { throw new RuntimeException("Expected Rule exception"); } }
/** * @author Alexander Wert * */ @Rule(name = "RuleD") public class RuleD { @TagValue(type = Tags.ROOT_TAG) String input; @Action(resultTag = "D") public int action() { throw new RuntimeException("Expected Rule exception"); } }
/** * @author Alexander Wert * */ @Rule public class AnnotatedSuperClass { @TagValue(type = "Test") public int par3 = 1; /** * */ public AnnotatedSuperClass(int x) { par3 = x; } @Action(resultTag = "Test2") private void actionD() { } }
/** * @author Alexander Wert * */ @Rule(name = "RuleG") public class RuleG { @TagValue(type = "A") String input1; @Condition public boolean condition() { return false; } @Action(resultTag = "G") public String action() { return input1; } }
@Rule(name = "GlobalContextRule") public class GlobalContextRule {
@Rule(name = "CauseStructureRule") public class CauseStructureRule {
@Rule(name = "TimeWastingOperationsRule") public class TimeWastingOperationsRule {
/** * @author Alexander Wert * */ @Rule(name = "RuleC") public class RuleC { @TagValue(type = "A") String input; @TagValue(type = "B") int input2; @Action(resultTag = "C") public int action() { return input2 + 2; } }
@Rule(name = "ProblemContextRule") public class ProblemContextRule {
/** * @author Alexander Wert * */ @Rule(name = "RuleWithSessionVariable") public class RuleWithSessionVariable { @TagValue(injectionStrategy = TagValue.InjectionStrategy.BY_VALUE, type = Tags.ROOT_TAG) String input; @SessionVariable(name = "sessionVar") String sessionVar; @Action(resultTag = "A") public String action() { return input + sessionVar; } }
/** * @author Alexander Wert * */ @Rule(name = "RuleC") public class RuleC { @TagValue(type = "A") String input; @TagValue(type = "B") int input2; @Action(resultTag = "C") public int action() { return input2 + 2; } }