Package nzilbb.editpath
Class EqualsComparator<T>
- java.lang.Object
-
- nzilbb.editpath.EqualsComparator<T>
-
- All Implemented Interfaces:
Comparator<T>
public class EqualsComparator<T> extends Object implements Comparator<T>
Implementation of IComparator that uses java.lang.Object.equals(Object) to determine equality or not. This is used as a default comparison method forDefaultEditComparator
, but can also be used as an adapter for customising the equals comparison, e.g.:// case-insensitive comparison new EqualsComparator<String>() { public int compare(String o1, String o2) { return o1.toLowerCase().compareTo(o2.toLowerCase()); } }
NB This comparator cannot be used for ordering elements, as it only returns 0 (for "equal") or 1 (for "not equal").
- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Constructor Summary
Constructors Constructor Description EqualsComparator()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(T o1, T o2)
Compares two objects for equality only.boolean
equals(Object obj)
Returns true iff this == object-
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Method Detail
-
compare
public int compare(T o1, T o2)
Compares two objects for equality only.NB This cannot be used for ordering elements, as it only returns 0 or 1.
- Specified by:
compare
in interfaceComparator<T>
- Returns:
- 0 if o1.equals(o2), 1 otherwise,
-
-