Mister Nono wrote
... only the last car is in the TreeMap
Thats why I said "/you need Lists or Maps as values of the TreeMap/".
*Here is fast solution:*
import Vehicle
import java.util.*
rule "Print grouped vehicles"
when $map : Map() from accumulate ($v : Vehicle($w : wheels),
init(TreeMap map=new TreeMap()),
action( if(map.containsKey($w)) ((List)map.get($w)).add($v);
else map.put($w, new ArrayList(Arrays.asList($v)));),
result(map))
then System.out.println($map);
end
--
View this message in context:
http://drools.46999.n3.nabble.com/To-group-some-objects-by-type-tp4022085...
Sent from the Drools: User forum mailing list archive at
Nabble.com.