[rules-users] Custom Evaluator compile time error, If I am upgrading from drool 5.0 to 5.3
Wolfgang Laun
wolfgang.laun at gmail.com
Tue Jan 24 04:22:01 EST 2012
Use OBJECT_TYPE instead of STRING_TYPE:
addEvaluator( ValueType.OBJECT_TYPE,
super( ValueType.OBJECT_TYPE, ...)
But consider using the built-in operator "in", e.g.:
Student(code in ("426656000", "426979002", "427295004" ) )
-W
On 24/01/2012, kashif10 <kash452 at yahoo.com> wrote:
> Hi,
>
> Our current code is using drools 5.0.
> We have some custom evaluators, which are working fine with 5.0.
>
> example
> *Code from Rule:*
> Student(code compareCode "426656000, 426979002, 427295004" )
>
> Where Student is a class & "code" is String field in that class. &
> compareCode is a custom operator using custom evaluator. as follows.
>
> *code from OP class:*
> public static final Operator COMPARE_CODE =
> Operator.addOperatorToRegistry( "compareCode",
> false );
>
>
> *Part from Evaluator Definitions class*
>
> private EvaluatorCache evaluators = new EvaluatorCache() {
> private static final long serialVersionUID = 100L;
> {
> addEvaluator( ValueType.STRING_TYPE, D1Operator.COMPARE_CODE,
>
> CodeEvaluator.INSTANCE );
> }
> };
>
>
>
>
>
> public static class CodeEvaluator extends BaseEvaluator {
>
> private static final long serialVersionUID = 100L;
> public final static Evaluator INSTANCE = new CodeEvaluator();
>
> public CodeEvaluator() {
> super( ValueType.STRING_TYPE,
> D1Operator.COMPARE_CODE );
> }
>
> public boolean evaluate(InternalWorkingMemory workingMemory,
> final InternalReadAccessor extractor,
> final Object object1,
> final FieldValue object2) {
> final Object value1 = extractor.getValue( workingMemory,
> object1 );
>
> //System.out.println("************* in
> CodeEqualEvaluator.evaluate");
> final Object value2 = object2.getValue();
> if ( value1 == null ) {
> return value2 == null;
> }
> //return value1.equals( value2 );
> return Utility.checkCode((String)value2, (String)value1);
>
> }
>
>
> Problem:
> Now If I update my Eclipse Drool plugin to 5.2.1 or 5.3 I start getting
> error
> Evaluator does not support type 'ValueType = 'Object'
> see attached snapshot/
>
> http://drools.46999.n3.nabble.com/file/n3683440/Drool_problem.jpg
> Drool_problem.jpg
>
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Custom-Evaluator-compile-time-error-If-I-am-upgrading-from-drool-5-0-to-5-3-tp3683440p3683440.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list