public class HumanComparator extends Object implements Comparator<String>
CollatedHumanComparator. Pretty efficient but still slower than
String.compareTo().| Modifier and Type | Class and Description |
|---|---|
static class |
HumanComparator.CharType |
| Modifier and Type | Field and Description |
|---|---|
static Comparator<String> |
DEFAULT_HUMAN_COMPARATOR |
| Constructor and Description |
|---|
HumanComparator()
Default constructor which does nothing.
|
HumanComparator(HumanComparator.CharType[] sortOrder)
Constructor specifying all the character type order.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compare(String str1,
String str2) |
static Comparator<String> |
getInstance()
Returns a singleton comparator that implements the default behaviour.
|
HumanComparator.CharType[] |
getSortOrder() |
void |
setSortOrder(HumanComparator.CharType[] sortOrder)
Set the order in which letters, numbers and everything else is presented.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic static final Comparator<String> DEFAULT_HUMAN_COMPARATOR
public HumanComparator()
public HumanComparator(HumanComparator.CharType[] sortOrder)
sortOrder - see setSortOrderpublic static Comparator<String> getInstance()
public int compare(String str1, String str2)
compare in interface Comparator<String>public HumanComparator.CharType[] getSortOrder()
public void setSortOrder(HumanComparator.CharType[] sortOrder)
sortOrder - Must be an array of CharType containing
exactly 3 elements each of which must be distinct.IllegalArgumentException - if being called on the result of
HumanStringComparator.getInstance() or
sortOrder is not exactly 3 different
CharType.Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.