Search in sources :

Example 1 with Pattern

use of org.drools.model.Pattern in project drools by kiegroup.

the class AccumulatePatternImpl method findPatternImplSource.

private Pattern findPatternImplSource() {
    if (condition instanceof Pattern) {
        return (Pattern) condition;
    }
    final Variable source = getAccumulateFunctions()[0].getSource();
    for (Condition subCondition : condition.getSubConditions()) {
        if (subCondition instanceof PatternImpl) {
            PatternImpl patternImpl = (PatternImpl) subCondition;
            boolean isSource = patternImpl.getBindings().stream().anyMatch(b -> (b instanceof Binding) && ((Binding) b).getBoundVariable().equals(source));
            if (isSource) {
                return patternImpl;
            }
        }
    }
    return null;
}
Also used : Condition(org.drools.model.Condition) Binding(org.drools.model.Binding) AccumulatePattern(org.drools.model.AccumulatePattern) Pattern(org.drools.model.Pattern) Variable(org.drools.model.Variable)

Aggregations

AccumulatePattern (org.drools.model.AccumulatePattern)1 Binding (org.drools.model.Binding)1 Condition (org.drools.model.Condition)1 Pattern (org.drools.model.Pattern)1 Variable (org.drools.model.Variable)1