Package com.google.common.collect
Class NaturalOrdering
- All Implemented Interfaces:
Serializable,Comparator<Comparable<?>>
An ordering that uses the natural order of the values.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.collect.Ordering
Ordering.ArbitraryOrdering, Ordering.IncomparableValueException -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final NaturalOrderingprivate Ordering<Comparable<?>>private Ordering<Comparable<?>>private static final longFields inherited from class com.google.common.collect.Ordering
LEFT_IS_GREATER, RIGHT_IS_GREATER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompare(Comparable<?> left, Comparable<?> right) <S extends Comparable<?>>
Ordering<S>Returns an ordering that treatsnullas less than all other values and usesthisto compare non-null values.<S extends Comparable<?>>
Ordering<S>Returns an ordering that treatsnullas greater than all other values and uses this ordering to compare non-null values.private Object<S extends Comparable<?>>
Ordering<S>reverse()Returns the reverse of this ordering; theOrderingequivalent toCollections.reverseOrder(Comparator).toString()Methods inherited from class com.google.common.collect.Ordering
allEqual, arbitrary, binarySearch, compound, compound, explicit, explicit, from, from, greatestOf, greatestOf, immutableSortedCopy, isOrdered, isStrictlyOrdered, leastOf, leastOf, lexicographical, max, max, max, max, min, min, min, min, natural, onKeys, onResultOf, sortedCopy, usingToStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
INSTANCE
-
nullsFirst
-
nullsLast
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
NaturalOrdering
private NaturalOrdering()
-
-
Method Details
-
compare
- Specified by:
comparein interfaceComparator<Comparable<?>>- Specified by:
comparein classOrdering<Comparable<?>>
-
nullsFirst
Description copied from class:OrderingReturns an ordering that treatsnullas less than all other values and usesthisto compare non-null values.The returned object is serializable if this object is serializable.
Java 8 users: Use
Comparator.nullsFirst(thisComparator)instead.- Overrides:
nullsFirstin classOrdering<Comparable<?>>
-
nullsLast
Description copied from class:OrderingReturns an ordering that treatsnullas greater than all other values and uses this ordering to compare non-null values.The returned object is serializable if this object is serializable.
Java 8 users: Use
Comparator.nullsLast(thisComparator)instead.- Overrides:
nullsLastin classOrdering<Comparable<?>>
-
reverse
Description copied from class:OrderingReturns the reverse of this ordering; theOrderingequivalent toCollections.reverseOrder(Comparator).Java 8 users: Use
thisComparator.reversed()instead.- Overrides:
reversein classOrdering<Comparable<?>>
-
readResolve
-
toString
-