use of org.drools.model.constraints.SingleConstraint2 in project drools by kiegroup.
the class LambdaConstraintTestUtil method createLambdaConstraint2.
public static <T, A, B> LambdaConstraint createLambdaConstraint2(Class<A> patternClass, Class<B> rightClass, Pattern pattern, Pattern varPattern, String varName, Predicate2<A, B> predicate, Index<T, ?> index) {
String patternName = "GENERATED_$pattern_" + patternClass.getSimpleName();
DeclarationImpl<A> declA = new DeclarationImpl<A>(patternClass, patternName);
DeclarationImpl<B> declB = new DeclarationImpl<B>(rightClass, varName);
SingleConstraint2<A, B> singleConstraint = new SingleConstraint2<A, B>(declA, declB, predicate);
singleConstraint.setIndex(index);
Declaration patternDecl = new Declaration(patternName, new PatternExtractor(new ClassObjectType(patternClass, false)), pattern, false);
Declaration varDecl = new Declaration(varName, new PatternExtractor(new ClassObjectType(rightClass, false)), varPattern, false);
ConstraintEvaluator constraintEvaluator = new ConstraintEvaluator(new Declaration[] { patternDecl, varDecl }, singleConstraint);
return new LambdaConstraint(constraintEvaluator);
}
Aggregations