public enum Comparison extends Enum<Comparison>
Safe representation of the result of a comparison (better than int).
Modifier and Type | Method and Description |
---|---|
static <T> Comparison |
compare(Comparator<T> comparator,
T a,
T b)
Compares the two objects using the
Comparator . |
static <T extends Comparable<T>> |
compare(T a,
T b)
Compares the two
Comparable s and returns the result. |
static Comparison |
from(int compareToResult)
Returns a Comparison from the given result of a call to
Comparable.compareTo(Object) or Comparator.compare(Object, Object) . |
<T> T |
lesserEqualGreater(T lesser,
T equal,
T greater)
Returns the appropriate T based on the Comparison value.
|
static Comparison |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Comparison[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Comparison LESSER
public static final Comparison EQUAL
public static final Comparison GREATER
public static Comparison[] values()
for (Comparison c : Comparison.values()) System.out.println(c);
public static Comparison valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null@CheckReturnValue @Nullable public <T> T lesserEqualGreater(@Nullable T lesser, @Nullable T equal, @Nullable T greater)
Returns the appropriate T based on the Comparison value.
@CheckReturnValue public static <T extends Comparable<T>> Comparison compare(T a, T b)
Compares the two Comparable
s and returns the result.
@CheckReturnValue public static <T> Comparison compare(Comparator<T> comparator, @Nullable T a, @Nullable T b)
Compares the two objects using the Comparator
.
@CheckReturnValue public static Comparison from(int compareToResult)
Returns a Comparison from the given result of a call to Comparable.compareTo(Object)
or Comparator.compare(Object, Object)
.