Numbers such that Longs occur before Integers.
Only the specified instanceOrder classes are considered during comparison.
If two objects are both instances of the ordered type this comparator will return a
value of 0. Consider combining with Comparator#thenComparing(Comparator)
if additional sorting is required.
Comparator#thenComparing(Comparator)
| Modifier and Type | Field and Description |
|---|---|
| private final Class |
| Access | Constructor and Description |
|---|---|
| public | InstanceComparator(Class<?>...
the ordered list of classes that should be used when comparing
objects. Classes earlier in the list will be given a higher priority. instanceOrder)Create a new |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(T
the first object to be compared. o1, T the second object to be compared. o2)Implements java. |
| private int |
| instanceOrder | back to summary |
|---|---|
| private final Class<?>[] instanceOrder | |
| InstanceComparator | back to summary |
|---|---|
| public InstanceComparator(Class<?>... instanceOrder) Create a new
| |
| compare | back to summary |
|---|---|
| public int compare(T o1, T o2) Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| getOrder | back to summary |
|---|---|
| private int getOrder(T object) | |