Top Description Inners Constructors Methods
java.util

pack-priv Class Comparators

extends Object
Class Inheritance
Imports
java.io.Serializable, java.util.function.BinaryOperator, .Function, .ToDoubleFunction, .ToIntFunction, .ToLongFunction

Package private supporting class for Comparator.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum
Comparators.NaturalOrderComparator

Compares Comparable objects in natural order.

pack-priv static class
Comparators.NullComparator<T>

Null-friendly comparators

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Comparatorsback to summary
private Comparators()
java.util back to summary

pack-priv final Enum Comparators.NaturalOrderComparator

extends Enum<Comparators.NaturalOrderComparator>
implements Comparator<Comparable<Object>>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

Compares Comparable objects in natural order.
See Also
Comparable

Field Summary

Modifier and TypeField and Description
public static final Comparators.NaturalOrderComparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(Comparable<Object>
the first object to be compared.
c1
,
Comparable<Object>
the second object to be compared.
c2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

public Comparator<Comparable<Object>>
reversed()

Overrides default java.util.Comparator.reversed.

Returns a comparator that imposes the reverse ordering of this comparator.

public static Comparators.NaturalOrderComparator
public static Comparators.NaturalOrderComparator[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final Comparators.NaturalOrderComparator INSTANCE

Constructor Detail

NaturalOrderComparatorback to summary
private NaturalOrderComparator()

Method Detail

compareback to summary
public int compare(Comparable<Object> c1, Comparable<Object> c2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

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 signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
c1:Comparable<Object>

the first object to be compared.

c2:Comparable<Object>

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override
reversedback to summary
public Comparator<Comparable<Object>> reversed()

Overrides default java.util.Comparator.reversed.

Doc from java.util.Comparator.reversed.

Returns a comparator that imposes the reverse ordering of this comparator.

Returns:Comparator<Comparable<Object>>

a comparator that imposes the reverse ordering of this comparator.

Annotations
@Override
valueOfback to summary
public static Comparators.NaturalOrderComparator valueOf(String name)
valuesback to summary
public static Comparators.NaturalOrderComparator[] values()
java.util back to summary

pack-priv final Class Comparators.NullComparator<T>

extends Object
implements Comparator<T>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.util.Comparator

Null-friendly comparators

Field Summary

Modifier and TypeField and Description
private final boolean
private final Comparator<T>
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
NullComparator(boolean nullFirst, Comparator<? super T> real)

Method Summary

Modifier and TypeMethod and Description
public int
compare(T
the first object to be compared.
a
,
T
the second object to be compared.
b
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

public Comparator<T>
reversed()

Overrides default java.util.Comparator.reversed.

Returns a comparator that imposes the reverse ordering of this comparator.

public Comparator<T>
thenComparing(Comparator<? super T>
the other comparator to be used when this comparator compares two objects that are equal.
other
)

Overrides default java.util.Comparator.thenComparing.

Returns a lexicographic-order comparator with another comparator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nullFirstback to summary
private final boolean nullFirst
realback to summary
private final Comparator<T> real
Annotations
@SuppressWarnings:serial
serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial

Constructor Detail

NullComparatorback to summary
pack-priv NullComparator(boolean nullFirst, Comparator<? super T> real)
Annotations
@SuppressWarnings:unchecked

Method Detail

compareback to summary
public int compare(T a, T b)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

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 signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
a:T

the first object to be compared.

b:T

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override
reversedback to summary
public Comparator<T> reversed()

Overrides default java.util.Comparator.reversed.

Doc from java.util.Comparator.reversed.

Returns a comparator that imposes the reverse ordering of this comparator.

Returns:Comparator<T>

a comparator that imposes the reverse ordering of this comparator.

Annotations
@Override
thenComparingback to summary
public Comparator<T> thenComparing(Comparator<? super T> other)

Overrides default java.util.Comparator.thenComparing.

Doc from java.util.Comparator.thenComparing.

Returns a lexicographic-order comparator with another comparator. If this Comparator considers two elements equal, i.e. compare(a, b) == 0, other is used to determine the order.

The returned comparator is serializable if the specified comparator is also serializable.

Parameters
other:Comparator<? super T>

the other comparator to be used when this comparator compares two objects that are equal.

Returns:Comparator<T>

a lexicographic-order comparator composed of this and then the other comparator

Annotations
@Override