Are you passing in an array of FactHandles? If not you can't cast them to FactHandle.
If you're passing in objects that are in WM, you can get their FactHandle by calling
WorkingMemory.getFactHandle(Object)
Otherwise, you can either constrain the generic T, or just use an array of FactHandle.
(FactHandle is an interface, after all.)
public static <T extends FactHandle> void remove(WorkingMemory workingMemory, T...
array) {
if(array == null) return;
for (T handle : array) {
workingMemory.retract(handle);
}
}
--- On Tue, 3/17/09, techy <techluver007(a)gmail.com> wrote:
From: techy <techluver007(a)gmail.com>
Subject: [rules-users] ClassCast exception while doing retract
To: rules-users(a)lists.jboss.org
Date: Tuesday, March 17, 2009, 3:04 PM
Hello,
My retract util func() is below and ClassCast exception is
thrown. Some help
please...
public static <T> void remove(WorkingMemory
workingMemory,T... array)
{
if(array == null || array.length == 0)
{
return;
}
for (int i=0;i<array.length;i++)
{
workingMemory.retract((FactHandle)
array[i]);
}
}
--
View this message in context:
http://www.nabble.com/ClassCast-exception-while-doing-retract-tp22566763p...
Sent from the drools - user mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users