public class ToStringComparator<T> extends java.lang.Object implements java.util.Comparator<T>
Note: this comparator imposes orderings that are inconsistent with equals.
In order to overcome the inconsistency with equals this comparator allows the introduction of a sub-comparator which is applied in cases of equality. I.e. if the two compared objects have the same name and they would be regarded as equal by this comparator, instead of 0 the result of the sub-comparator's comparison is returned.
|Modifier and Type||Field and Description|
The default NameComparator without a subComparator
|Constructor and Description|
Creates a new NameComparator object.
|Modifier and Type||Method and Description|
Compares its two arguments for order according to their names.
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected java.util.Comparator<? super java.lang.Object> sameNameSubCmp
public static final java.util.Comparator<java.lang.Object> DEFAULT
public ToStringComparator(java.util.Comparator<? super java.lang.Object> sameStringSubComparator)
sameStringSubComparator- if two objects with the same name are compared, this sub-comparator is applied if it is not null.
o1- an instance of interface Named.
o2- an instance of interface Named.