@Test public void pojoWithNoThenAnnotationDefaultsToNext() throws InvalidClassException { SampleRuleWithoutAnnotations sampleRule = new SampleRuleWithoutAnnotations(); RuleAdapter ruleAdapter = new RuleAdapter(sampleRule); Assert.assertEquals(0, ((List<Object>)ruleAdapter.getActions()).size()); }
@Override @SuppressWarnings("unchecked") public List<Object> getActions() { if (_rule.getActions().size() < 1) { List<Object> actionList = new ArrayList<>(); for (Method actionMethod : getAnnotatedMethods(Then.class, _pojoRule.getClass())) { actionMethod.setAccessible(true); Object then = getThenMethodAsBiConsumer(actionMethod).map(Object.class::cast) .orElse(getThenMethodAsConsumer(actionMethod).orElse(factMap -> { })); actionList.add(then); } _rule.getActions().addAll(actionList); } return _rule.getActions(); }
RuleAdapter implements Rule { @Override @SuppressWarnings("unchecked") public List<Object> getActions() { if (_rule.getActions().size() < 1) { List<Object> actionList = new ArrayList<>(); for (Method actionMethod : getAnnotatedMethods(Then.class, _pojoRule.getClass())) { actionMethod.setAccessible(true); Object then = getThenMethodAsBiConsumer(actionMethod).map(Object.class::cast) .orElse(getThenMethodAsConsumer(actionMethod).orElse(factMap -> { })); actionList.add(then); } _rule.getActions().addAll(actionList); } return _rule.getActions(); } }
RuleAdapter implements Rule { @Override @SuppressWarnings("unchecked") public List<Object> getActions() { if (_rule.getActions().size() < 1) { List<Object> actionList = new ArrayList<>(); for (Method actionMethod : getAnnotatedMethods(Then.class, _pojoRule.getClass())) { actionMethod.setAccessible(true); Object then = getThenMethodAsBiConsumer(actionMethod).map(Object.class::cast) .orElse(getThenMethodAsConsumer(actionMethod).orElse(factMap -> { })); actionList.add(then); } _rule.getActions().addAll(actionList); } return _rule.getActions(); } RuleAdapter(Object pojoRule, Rule rule); @SuppressWarnings("unchecked")  RuleAdapter(Object pojoRule); }
RuleAdapter implements Rule { @Override @SuppressWarnings("unchecked") public List<Object> getActions() { if (_rule.getActions().size() < 1) { List<Object> actionList = new ArrayList<>(); for (Method actionMethod : getAnnotatedMethods(Then.class, _pojoRule.getClass())) { actionMethod.setAccessible(true); Object then = getThenMethodAsBiConsumer(actionMethod).map(Object.class::cast) .orElse(getThenMethodAsConsumer(actionMethod).orElse(factMap -> { })); actionList.add(then); } _rule.getActions().addAll(actionList); } return _rule.getActions(); } RuleAdapter(Object pojoRule, Rule rule); @SuppressWarnings("unchecked")  RuleAdapter(Object pojoRule); @Override void addFacts(NameValueReferable... facts); @Override void addFacts(NameValueReferableMap facts); @Override void setFacts(NameValueReferableMap facts); @Override @SuppressWarnings("unchecked") void setCondition(Predicate condition); @Override void setRuleState(RuleState ruleState); @Override @SuppressWarnings("unchecked") void addAction(Consumer action); @Override @SuppressWarnings("unchecked") void addAction(BiConsumer action); @Override void addFactNameFilter(String... factNames); @Override NameValueReferableMap getFacts(); @Override @SuppressWarnings("unchecked") Predicate<NameValueReferableMap> getCondition(); @Override RuleState getRuleState(); @Override @SuppressWarnings("unchecked") List<Object> getActions(); @Override @SuppressWarnings("unchecked") boolean invoke(NameValueReferableMap facts); @Override @SuppressWarnings("unchecked") void setResult(Result result); @Override Optional<Result> getResult(); }
RuleAdapter implements Rule { @Override @SuppressWarnings("unchecked") public List<Object> getActions() { if (_rule.getActions().size() < 1) { List<Object> actionList = new ArrayList<>(); for (Method actionMethod : getAnnotatedMethods(Then.class, _pojoRule.getClass())) { actionMethod.setAccessible(true); Object then = getThenMethodAsBiConsumer(actionMethod).map(Object.class::cast) .orElse(getThenMethodAsConsumer(actionMethod).orElse(factMap -> { })); actionList.add(then); } _rule.getActions().addAll(actionList); } return _rule.getActions(); } RuleAdapter(Object pojoRule, Rule rule); @SuppressWarnings("unchecked")  RuleAdapter(Object pojoRule); @Override void addFacts(NameValueReferable... facts); @Override void addFacts(NameValueReferableMap facts); @Override void setFacts(NameValueReferableMap facts); @Override @SuppressWarnings("unchecked") void setCondition(Predicate condition); @Override void setRuleState(RuleState ruleState); @Override @SuppressWarnings("unchecked") void addAction(Consumer action); @Override @SuppressWarnings("unchecked") void addAction(BiConsumer action); @Override void addFactNameFilter(String... factNames); @Override NameValueReferableMap getFacts(); @Override @SuppressWarnings("unchecked") Predicate<NameValueReferableMap> getCondition(); @Override RuleState getRuleState(); @Override @SuppressWarnings("unchecked") List<Object> getActions(); @Override @SuppressWarnings("unchecked") boolean invoke(NameValueReferableMap facts); @Override @SuppressWarnings("unchecked") void setResult(Result result); @Override Optional<Result> getResult();  }