It looks like the value objects of the accumulate framework are always
Long's - even when they are Integers?
Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast
to java.lang.Integer
at
org.drools.base.accumulators.SumIntegerAccumulateFunction.accumulate(SumIntegerAccumulateFunction.java:36)
at
org.drools.base.accumulators.JavaAccumulatorFunctionExecutor.accumulate(JavaAccumulatorFunctionExecutor.java:79)
Here's the piece of code:
public void accumulate(Object context,
Object value) {
SumIntegerAccumulateFunction.SumData data =
(SumIntegerAccumulateFunction.SumData) context;
data.total += ((Integer) value).intValue(); // breaks
}
Here's the drl:
when
$totalDistance : Integer() from accumulate(
Hop($distance : distance),
sumInteger($distance)
);
Here's the Hop object:
public int getDistance() {
...
}
Look ma, no longs :) Still a ClassCastException on them though.
I must be missing something really obvious?
--
With kind regards,
Geoffrey De Smet