It's not sufficiently explicit that the comparator is used as an external equality check and, thus, only needs to reliably separate equal elements from unequal ones.
It's important for a developer to be certain that it's fine to implement such a comparator, for example, like this:
public static <T> Comparator<T> newEqualityComparator() {
return (o1, o2) -> Objects.equals(o1, o2) ? 0 : -1;
}
Not only does it go against ingrained practices, but it might also be flagged as suspicious by IDEs and static analysis tools. So, more help and reassurance from documentation is in order.
It's important for a developer to be certain that it's fine to implement such a comparator, for example, like this:
public static <T> Comparator<T> newEqualityComparator() {
return (o1, o2) -> Objects.equals(o1, o2) ? 0 : -1;
}
Not only does it go against ingrained practices, but it might also be flagged as suspicious by IDEs and static analysis tools. So, more help and reassurance from documentation is in order.