Search in sources :

Example 1 with AlphaIndexImpl

use of org.drools.model.index.AlphaIndexImpl in project drools by kiegroup.

the class LambdaConstraintTestUtil method createCheeseTypeEqualsConstraint.

public static LambdaConstraint createCheeseTypeEqualsConstraint(final String rightValue, int indexId) {
    // Typical LambdaConstraint used in drools-test-coverage. (type == "xxx")
    Pattern pattern = new Pattern(0, new ClassObjectType(Cheese.class));
    Predicate1<Cheese> predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.areNullSafeEquals(_this.getType(), rightValue));
    AlphaIndexImpl<Cheese, String> index = new AlphaIndexImpl<Cheese, String>(String.class, org.drools.model.Index.ConstraintType.EQUAL, indexId, _this -> _this.getType(), rightValue);
    return createLambdaConstraint1(Cheese.class, pattern, predicate, index);
}
Also used : Pattern(org.drools.core.rule.Pattern) DeclarationImpl(org.drools.model.impl.DeclarationImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) ClassObjectType(org.drools.core.base.ClassObjectType) Cheese(org.drools.mvel.model.Cheese)

Example 2 with AlphaIndexImpl

use of org.drools.model.index.AlphaIndexImpl in project drools by kiegroup.

the class LambdaConstraintTestUtil method createCheeseCharObjectTypeEqualsConstraint.

public static LambdaConstraint createCheeseCharObjectTypeEqualsConstraint(final char rightValue, int indexId) {
    // Typical LambdaConstraint used in drools-test-coverage. indexId is required when the test uses hashKey
    Pattern pattern = new Pattern(0, new ClassObjectType(Cheese.class));
    Predicate1<Cheese> predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.areNullSafeEquals(_this.getCharObjectType(), rightValue));
    AlphaIndexImpl<Cheese, Character> index = new AlphaIndexImpl<Cheese, Character>(Character.class, org.drools.model.Index.ConstraintType.EQUAL, indexId, _this -> _this.getCharObjectType(), (char) rightValue);
    return LambdaConstraintTestUtil.createLambdaConstraint1(Cheese.class, pattern, predicate, index);
}
Also used : Pattern(org.drools.core.rule.Pattern) DeclarationImpl(org.drools.model.impl.DeclarationImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) ClassObjectType(org.drools.core.base.ClassObjectType) Cheese(org.drools.mvel.model.Cheese)

Example 3 with AlphaIndexImpl

use of org.drools.model.index.AlphaIndexImpl in project drools by kiegroup.

the class LambdaConstraintTestUtil method createCheesePriceEqualsConstraint.

public static LambdaConstraint createCheesePriceEqualsConstraint(final int rightValue, int indexId) {
    // Typical LambdaConstraint used in drools-test-coverage. (price == xxx)
    Pattern pattern = new Pattern(0, new ClassObjectType(Cheese.class));
    Predicate1<Cheese> predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.areNullSafeEquals(_this.getPrice(), rightValue));
    AlphaIndexImpl<Cheese, Integer> index = new AlphaIndexImpl<Cheese, Integer>(Integer.class, org.drools.model.Index.ConstraintType.EQUAL, indexId, _this -> _this.getPrice(), rightValue);
    return createLambdaConstraint1(Cheese.class, pattern, predicate, index);
}
Also used : Pattern(org.drools.core.rule.Pattern) DeclarationImpl(org.drools.model.impl.DeclarationImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) ClassObjectType(org.drools.core.base.ClassObjectType) Cheese(org.drools.mvel.model.Cheese)

Example 4 with AlphaIndexImpl

use of org.drools.model.index.AlphaIndexImpl in project drools by kiegroup.

the class LambdaConstraintTestUtil method createCheeseCharTypeEqualsConstraint.

public static LambdaConstraint createCheeseCharTypeEqualsConstraint(final char rightValue, int indexId) {
    // Typical LambdaConstraint used in drools-test-coverage. indexId is required when the test uses hashKey
    Pattern pattern = new Pattern(0, new ClassObjectType(Cheese.class));
    Predicate1<Cheese> predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.areNullSafeEquals(_this.getCharType(), rightValue));
    AlphaIndexImpl<Cheese, Character> index = new AlphaIndexImpl<Cheese, Character>(Character.class, org.drools.model.Index.ConstraintType.EQUAL, indexId, _this -> _this.getCharType(), (char) rightValue);
    return LambdaConstraintTestUtil.createLambdaConstraint1(Cheese.class, pattern, predicate, index);
}
Also used : Pattern(org.drools.core.rule.Pattern) DeclarationImpl(org.drools.model.impl.DeclarationImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) ClassObjectType(org.drools.core.base.ClassObjectType) Cheese(org.drools.mvel.model.Cheese)

Example 5 with AlphaIndexImpl

use of org.drools.model.index.AlphaIndexImpl in project drools by kiegroup.

the class LambdaConstraintTestUtil method createCheesePriceGreaterConstraint.

public static LambdaConstraint createCheesePriceGreaterConstraint(final int rightValue, int indexId) {
    // Typical LambdaConstraint used in drools-test-coverage. (price > xxx)
    Pattern pattern = new Pattern(0, new ClassObjectType(Cheese.class));
    Predicate1<Cheese> predicate = new Predicate1.Impl<Cheese>(_this -> EvaluationUtil.greaterThan(_this.getPrice(), rightValue));
    AlphaIndexImpl<Cheese, Integer> index = new AlphaIndexImpl<Cheese, Integer>(Integer.class, org.drools.model.Index.ConstraintType.GREATER_THAN, indexId, _this -> _this.getPrice(), rightValue);
    return createLambdaConstraint1(Cheese.class, pattern, predicate, index);
}
Also used : Pattern(org.drools.core.rule.Pattern) DeclarationImpl(org.drools.model.impl.DeclarationImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) AlphaIndexImpl(org.drools.model.index.AlphaIndexImpl) ClassObjectType(org.drools.core.base.ClassObjectType) Cheese(org.drools.mvel.model.Cheese)

Aggregations

ClassObjectType (org.drools.core.base.ClassObjectType)5 Pattern (org.drools.core.rule.Pattern)5 DeclarationImpl (org.drools.model.impl.DeclarationImpl)5 AlphaIndexImpl (org.drools.model.index.AlphaIndexImpl)5 Cheese (org.drools.mvel.model.Cheese)5