Examples of LiteralConstraint


Examples of org.drools.rule.LiteralConstraint

       
        FieldValue fieldValue = FieldFactory.getFieldValue( value,
                                                            extractor.getValueType(),
                                                            null );

        return new LiteralConstraint( extractor,
                                      evaluator,
                                      fieldValue );
    }
View Full Code Here

Examples of org.drools.rule.LiteralConstraint

        final Evaluator evaluator = new EqualityEvaluatorsDefinition().getEvaluator( ValueType.STRING_TYPE,
                                                                                     Operator.EQUAL,
                                                                                     null );

        final LiteralConstraint constraint = new LiteralConstraint( extractor,
                                                                    evaluator,
                                                                    field );
        pattern.addConstraint( constraint );
        rule1.addPattern( pattern );

        rule1.setConsequence( new Consequence() {
            private static final long serialVersionUID = 510l;

            public void evaluate(final KnowledgeHelper knowledgeHelper,
                                 final WorkingMemory workingMemory) throws Exception {
            }

            public void readExternal(ObjectInput in) throws IOException,
                                                    ClassNotFoundException {

            }

            public void writeExternal(ObjectOutput out) throws IOException {

            }
           
            public String getName() {
                return "default";
            }
        } );

        final Rule rule2 = new Rule( "test2" );
        final ClassObjectType cheeseObjectType2 = new ClassObjectType( Cheese.class );
        final Pattern pattern2 = new Pattern( 0,
                                              cheeseObjectType2 );

        final FieldValue field2 = FieldFactory.getFieldValue( "stilton" );

        final LiteralConstraint constraint2 = new LiteralConstraint( extractor,
                                                                     evaluator,
                                                                     field2 );
        pattern2.addConstraint( constraint2 );
        rule2.addPattern( pattern2 );
View Full Code Here

Examples of org.drools.rule.LiteralConstraint

                           pkgBuilder.getErrors().isEmpty() );

        final Rule rule = pkgBuilder.getPackages()[0].getRule( "Test Rule" );
        final GroupElement and = rule.getLhs();
        final Pattern pat = (Pattern) and.getChildren().get( 0 );
        final LiteralConstraint fc = (LiteralConstraint) pat.getConstraints().get( 0 );
        assertTrue( "Wrong class. Expected java.math.BigDecimal. Found: " + fc.getField().getValue().getClass(),
                    fc.getField().getValue() instanceof BigDecimal );
    }
View Full Code Here

Examples of org.drools.rule.LiteralConstraint

                           pkgBuilder.getErrors().isEmpty() );

        final Rule rule = pkgBuilder.getPackages()[0].getRule( "Test Rule" );
        final GroupElement and = rule.getLhs();
        final Pattern pat = (Pattern) and.getChildren().get( 0 );
        final LiteralConstraint fc = (LiteralConstraint) pat.getConstraints().get( 0 );
        assertTrue( "Wrong class. Expected java.math.BigInteger. Found: " + fc.getField().getValue().getClass(),
                    fc.getField().getValue() instanceof BigInteger );
    }
View Full Code Here

Examples of org.drools.rule.LiteralConstraint

        final GroupElement or = (GroupElement) lhs.getChildren().get( 0 );
        assertLength( 1,
                      or.getChildren() );
        final Pattern pattern = (Pattern) or.getChildren().get( 0 );

        final LiteralConstraint literalConstarint = (LiteralConstraint) pattern.getConstraints().get( 0 );
    }
View Full Code Here

Examples of org.drools.rule.LiteralConstraint

        final GroupElement and = (GroupElement) lhs.getChildren().get( 0 );
        assertLength( 1,
                      and.getChildren() );
        final Pattern pattern = (Pattern) and.getChildren().get( 0 );

        final LiteralConstraint literalConstraint = (LiteralConstraint) pattern.getConstraints().get( 0 );
    }
View Full Code Here

Examples of org.drools.rule.LiteralConstraint

        final GroupElement not = (GroupElement) lhs.getChildren().get( 0 );
        assertLength( 1,
                      not.getChildren() );
        final Pattern pattern = (Pattern) not.getChildren().get( 0 );

        final LiteralConstraint literalConstarint = (LiteralConstraint) pattern.getConstraints().get( 0 );
    }
View Full Code Here

Examples of org.drools.rule.LiteralConstraint

        final GroupElement exists = (GroupElement) lhs.getChildren().get( 0 );
        assertLength( 1,
                      exists.getChildren() );
        final Pattern pattern = (Pattern) exists.getChildren().get( 0 );

        final LiteralConstraint literalConstarint = (LiteralConstraint) pattern.getConstraints().get( 0 );
    }
View Full Code Here

Examples of org.drools.rule.LiteralConstraint

        final Evaluator evaluator = registry.getEvaluator( ValueType.STRING_TYPE,
                                                           Operator.EQUAL,
                                                           null );

        final LiteralConstraint constraint = new LiteralConstraint( extractor,
                                                                    evaluator,
                                                                    field );
        pattern.addConstraint( constraint );
        rule.addPattern( pattern );
View Full Code Here

Examples of org.drools.rule.LiteralConstraint

            String mvelExpr = normalizeMVELLiteralExpression(vtype, field, expression, leftValue, operator, rightValue, restrictionDescr);
            return new MvelConstraint(context.getPkg().getName(), mvelExpr, operator);
        } else {
            LiteralRestriction restriction = buildLiteralRestriction(context, extractor, restrictionDescr, field, vtype);
            return restriction != null ? new LiteralConstraint(extractor, restriction) : null;
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.