{@code}if (Ordering.from(comparator).reverse().isOrdered(list)) ... }}The {@link #from(Comparator)} method returns the equivalent {@code Ordering}instance for a pre-existing comparator. You can also skip the comparator step and extend {@code Ordering} directly:
{@code}OrderingExcept as noted, the orderings returned by the factory methods of this class are serializable if and only if the provided instances that back them are. For example, if {@code ordering} and {@code function} can themselves beserialized, then {@code ordering.onResultOf(function)} can as well. @author Jesse Wilson @author Kevin Bourrillion @since Guava release 02 (imported from Google Collections Library)byLengthOrdering = new Ordering () public int compare(String left, String right) { return Ints.compare(left.length(), right.length()); } };}
nt1
, for which {@link #getOperand operand}evaluates to v1
, and a second node-tuple, nt2
, for which {@link #getOperand operand} evaluates to v2
:Ascending
, then:v1
is null, v2
is null, or both v1
and v2
are null, the relative order of nt1
and nt2
is implementation determined, otherwisev1
is a different property type than v2
, the relative order of nt1
and nt2
is implementation determined, otherwisev1
is ordered before v2
, then nt1
precedes nt2
, otherwisev1
is ordered after v2
, then nt2
precedes nt1
, otherwisent1
and nt2
is implementation determined and may be arbitrary.Descending
, then:v1
is null, v2
is null, or both v1
and v2
are null, the relative order of nt1
and nt2
is implementation determined, otherwisev1
is a different property type than v2
, the relative order of nt1
and nt2
is implementation determined, otherwisev1
is ordered before v2
, then nt2
precedes nt1
, otherwisev1
is ordered after v2
, then nt1
precedes nt2
, otherwisent1
and nt2
is implementation determined and may be arbitrary.nt1
, for which {@link #getOperand operand}evaluates to v1
, and a second node-tuple, nt2
, for which {@link #getOperand operand} evaluates to v2
:Ascending
, then:v1
is null, v2
is null, or both v1
and v2
are null, the relative order of nt1
and nt2
is implementation determined, otherwisev1
is a different property type than v2
, the relative order of nt1
and nt2
is implementation determined, otherwisev1
is ordered before v2
, then nt1
precedes nt2
, otherwisev1
is ordered after v2
, then nt2
precedes nt1
, otherwisent1
and nt2
is implementation determined and may be arbitrary.Descending
, then:v1
is null, v2
is null, or both v1
and v2
are null, the relative order of nt1
and nt2
is implementation determined, otherwisev1
is a different property type than v2
, the relative order of nt1
and nt2
is implementation determined, otherwisev1
is ordered before v2
, then nt2
precedes nt1
, otherwisev1
is ordered after v2
, then nt1
precedes nt2
, otherwisent1
and nt2
is implementation determined and may be arbitrary.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|