Package com.jidesoft.comparator
Class CharSequenceComparator
java.lang.Object
com.jidesoft.comparator.CharSequenceComparator
- All Implemented Interfaces:
Serializable
,Comparator<Object>
A Comparator that compares CharSequence objects (including String and StringBuffer as both extend CharSequence.
Throws ClassCastExceptions if the objects are not CharSequence, or if they are null. If both objects are null, they
will be treated as equal. If one is null and the other is not, the null value will be treated as smaller then
non-null value.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a CharSequenceComparator.CharSequenceComparator
(boolean caseSensitive) -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Checks if the case is sensitive when comparing.void
setCaseSensitive
(boolean caseSensitive) Sets the case sensitive flag.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
CONTEXT
-
CONTEXT_IGNORE_CASE
-
-
Constructor Details
-
CharSequenceComparator
public CharSequenceComparator()Constructs a CharSequenceComparator. -
CharSequenceComparator
public CharSequenceComparator(boolean caseSensitive)
-
-
Method Details
-
isCaseSensitive
public boolean isCaseSensitive()Checks if the case is sensitive when comparing.- Returns:
- true if the comparator is case sensitive.
-
setCaseSensitive
public void setCaseSensitive(boolean caseSensitive) Sets the case sensitive flag. By default, it's true meaning the comparator is case sensitive.- Parameters:
caseSensitive
- true or false.
-
compare
- Specified by:
compare
in interfaceComparator<Object>
-