Assume a collection of objects exists and there is an object
implementing Predicate interface. Also let's say that evaluate(Object
obj) method returns a number of distinct objects (out of this
collection) and the number is noticeably less than total amount of
objects in the collection. Is there a way to get all collections grouped
by the predicator? An example may be schematically written like:
 
class Man {
String name;
int age;
}
 
class AgePredicator implements Predicate {
    int age;
    boolean evaluate (Object obj) {
Man man = (Man)obj;
return man.age == this.age;
}
 
 
collection men = { ('Isac', 35), ('Jerry', 32), ('Gonsales', 35),
('Moshe' , 22), ('Hans', 32), ('Mussa', 32)}
 
afer grouping it's supposed to get 3 collections:
 
('Isac', 35), ('Gonsales', 35), 
('Jerry', 32), ('Hans', 32), ('Mussa', 32)}
('Moshe' , 22), 
 
 
Do we have something in the API do achieve it easily?
 
 
_______________________
Roman Rytov

Reply via email to