I'm struggling to reduce a list :
Let's say I have a List<Item> listItems with an Item class defined such as :
public class Item {
private String effect;
private String value;
public String getEffect() {
return effect;
}
public void setEffect(String effect) {
this.effect = effect;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
Now, in my listItems list, I have some elements with the same effect property.
I want to remove all element from my listItems list with the same effect property except the one with the higher value property. (value is number represented as a String).
Also, I wanna keep all the element with an unique effect property.
How can I achieve that ? I guess I'm gonna have to deal with Comparator.