Package uk.ac.starlink.datanode.nodes
Class StringComparator
java.lang.Object
uk.ac.starlink.datanode.nodes.StringComparator
- All Implemented Interfaces:
Comparator
A very simple implementation of the
Comparator
interface.
It is suitable for use on any objects for which the toString
method provides a suitable basis for object comparison.
You might think that calling java.text.Collator.getInstance
ought to provide much the same thing; however that gives you a
compare
method which casts to String
rather
than calling the toString
method on its arguments,
leading to a ClassCastException
in most useful cases.
I wonder why it does that?
- Version:
- $Id$
- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
StringComparator
public StringComparator()
-
-
Method Details
-
compare
- Specified by:
compare
in interfaceComparator
-
equals
- Specified by:
equals
in interfaceComparator
- Overrides:
equals
in classObject
-