java how to check if a list contains an object code example
Example 1: java list of a class has a string that is equal to
public boolean containsName(final List<MyObject> list, final String name){
return list.stream().map(MyObject::getName).filter(name::equals).findFirst().isPresent();
}
Example 2: java list contains object with property
boolean found = list.stream()
.anyMatch(p -> p.name.equals(personName));