Here is my problem I have a list of 'System Exceptions' and I need to select distinct values from the list based on two keys. So I am creating a compositeKey and storing it in a list as a string 'key1:key2' Is there a better approach to this ?
Collection uniqueExceptions = CollectionUtils.select(allSubareaExceptions, new Predicate(){
private List<String> ids = new ArrayList<String>();
public boolean evaluate(Object obj) {
....domain.Exception ex = (....domain.Exception)obj;
String compositeKey = ex.getProcedure().getSubarea().getId() +":"+ex.getProcedure().getId();
if(ids.contains(compositeKey) == false){
ids.add(compositeKey);
return true;
}
return false;
}
});