Search in sources :

Example 1 with DeclarationImpl

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);
}
Also used : SingleConstraint2(org.drools.model.constraints.SingleConstraint2) ClassObjectType(org.drools.core.base.ClassObjectType) PatternExtractor(org.drools.core.spi.PatternExtractor) LambdaConstraint(org.drools.modelcompiler.constraints.LambdaConstraint) ConstraintEvaluator(org.drools.modelcompiler.constraints.ConstraintEvaluator) DeclarationImpl(org.drools.model.impl.DeclarationImpl) Declaration(org.drools.core.rule.Declaration)

Example 2 with DeclarationImpl

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);
}
Also used : SingleConstraint1(org.drools.model.constraints.SingleConstraint1) LambdaConstraint(org.drools.modelcompiler.constraints.LambdaConstraint) DeclarationImpl(org.drools.model.impl.DeclarationImpl) Declaration(org.drools.core.rule.Declaration) ConstraintEvaluator(org.drools.modelcompiler.constraints.ConstraintEvaluator)

Aggregations

Declaration (org.drools.core.rule.Declaration)2 DeclarationImpl (org.drools.model.impl.DeclarationImpl)2 ConstraintEvaluator (org.drools.modelcompiler.constraints.ConstraintEvaluator)2 LambdaConstraint (org.drools.modelcompiler.constraints.LambdaConstraint)2 ClassObjectType (org.drools.core.base.ClassObjectType)1 PatternExtractor (org.drools.core.spi.PatternExtractor)1 SingleConstraint1 (org.drools.model.constraints.SingleConstraint1)1 SingleConstraint2 (org.drools.model.constraints.SingleConstraint2)1