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 NaturalOrdering
private Ordering
<Comparable<?>> private Ordering
<Comparable<?>> private static final long
Fields inherited from class com.google.common.collect.Ordering
LEFT_IS_GREATER, RIGHT_IS_GREATER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
compare
(Comparable<?> left, Comparable<?> right) <S extends Comparable<?>>
Ordering<S> Returns an ordering that treatsnull
as less than all other values and usesthis
to compare non-null values.<S extends Comparable<?>>
Ordering<S> Returns an ordering that treatsnull
as 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; theOrdering
equivalent 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, usingToString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:
compare
in interfaceComparator<Comparable<?>>
- Specified by:
compare
in classOrdering<Comparable<?>>
-
nullsFirst
Description copied from class:Ordering
Returns an ordering that treatsnull
as less than all other values and usesthis
to compare non-null values.The returned object is serializable if this object is serializable.
Java 8+ users: Use
Comparator.nullsFirst(thisComparator)
instead.- Overrides:
nullsFirst
in classOrdering<Comparable<?>>
-
nullsLast
Description copied from class:Ordering
Returns an ordering that treatsnull
as 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:
nullsLast
in classOrdering<Comparable<?>>
-
reverse
Description copied from class:Ordering
Returns the reverse of this ordering; theOrdering
equivalent toCollections.reverseOrder(Comparator)
.Java 8+ users: Use
thisComparator.reversed()
instead.- Overrides:
reverse
in classOrdering<Comparable<?>>
-
readResolve
-
toString
-