bb.util
Class CaseInsensitiveComparator
java.lang.Object
bb.util.CaseInsensitiveComparator
- All Implemented Interfaces:
- Serializable, Comparator<String>
public class CaseInsensitiveComparator
- extends Object
- implements Comparator<String>, Serializable
Imposes an ordering on Strings that is inconsistent with equals; see compare
for details.
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
- Author:
- Brent Boyer
- See Also:
- Serialized Form
Method Summary |
int |
compare(String s1,
String s2)
Converts s1 and s2 to lower case and then returns s1. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
CaseInsensitiveComparator
public CaseInsensitiveComparator()
compare
public int compare(String s1,
String s2)
throws IllegalArgumentException
- Converts s1 and s2 to lower case and then returns
s1.compareTo
(s2)
.
So, the result is consistent with equalsIgnoreCase
but is inconsistent with equals
.
- Specified by:
compare
in interface Comparator<String>
- Throws:
IllegalArgumentException
- if s1 or s2 is null