use of org.drools.model.impl.DeclarationImpl 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);
}
use of org.drools.model.impl.DeclarationImpl in project drools by kiegroup.
the class LambdaConstraintTestUtil method createLambdaConstraint1.
public static <T> LambdaConstraint createLambdaConstraint1(Class<T> patternClass, Pattern pattern, Predicate1<T> predicate, Index<T, ?> index) {
String patternName = "GENERATED_$pattern_" + patternClass.getSimpleName();
DeclarationImpl<T> decl = new DeclarationImpl<T>(patternClass, patternName);
SingleConstraint1<T> singleConstraint = new SingleConstraint1<T>(decl, predicate);
singleConstraint.setIndex(index);
Declaration coreDecl = new Declaration(patternName, null, pattern, false);
ConstraintEvaluator constraintEvaluator = new ConstraintEvaluator(new Declaration[] { coreDecl }, singleConstraint);
return new LambdaConstraint(constraintEvaluator);
}
Aggregations