Comparator<Object>
public class NumberComparator extends Object implements Comparator<Object>
Modifier and Type | Field | Description |
---|---|---|
static ComparatorContext |
CONTEXT_ABSOLUTE |
Comparator Context to compare two values using the absolute value.
|
Modifier | Constructor | Description |
---|---|---|
protected |
NumberComparator() |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
int |
compare(Object o1,
Object o2) |
Compares two Numbers.
|
static NumberComparator |
getInstance() |
Returns NumberComparator singleton.
|
boolean |
isAbsolute() |
Checks if if the values are compared using the absolute values.
|
void |
setAbsolute(boolean absolute) |
Sets the flag to compare the values using the absolute value.
|
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public static final ComparatorContext CONTEXT_ABSOLUTE
protected NumberComparator()
public static NumberComparator getInstance()
public int compare(Object o1, Object o2)
compare
in interface Comparator<Object>
o1
- the first object to be comparedo2
- the second object to be comparedpublic boolean isAbsolute()
public void setAbsolute(boolean absolute)
absolute
- true or false.