[rules-dev] SumIntegerAccumulateFunction not possible?
Mark Proctor
mproctor at codehaus.org
Sat Aug 11 10:47:11 EDT 2007
ok, that looks like a bug. please open a jira for it. It may well be
that we do only return Longs and Doubles, to save on duplicate apis, but
there should still be adequate coercion
Mark
Geoffrey De Smet wrote:
> 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?
>
More information about the rules-dev
mailing list