final ClassFieldReader extractor = store.getReader( Cheese.class,
"type",
getClass().getClassLoader() );
final FieldValue field = FieldFactory.getFieldValue( "cheddar" );
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 );