Package com.helger.base.compare
Enum Class ESortOrder
- All Implemented Interfaces:
ISortOrderIndicator,Serializable,Comparable<ESortOrder>,Constable
Defines possible sort orders. The default is
ASCENDING sorting.- Author:
- Philip Helger
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription@NonNull ESortOrderGet the alternate sort order.static @Nullable ESortOrdergetFromValue(int nValue, @Nullable ESortOrder eDefault) Get theESortOrdermatching the provided value, with a custom default.static @NonNull ESortOrdergetFromValueOrDefault(int nValue) Get theESortOrdermatching the provided value, defaulting toDEFAULT.intgetValue()@NonNull Stringbooleanstatic ESortOrderReturns the enum constant of this class with the specified name.static ESortOrder[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from interface com.helger.base.compare.ISortOrderIndicator
isDescending
-
Enum Constant Details
-
ASCENDING
-
DESCENDING
-
-
Field Details
-
DEFAULT
The default sort order isASCENDING
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getValue
@Nonnegative public int getValue()- Returns:
- The associated value for this sort order. The value can directly be used in compare methods to multiply the initial return value with this value to have the correct ordering.
-
getValueAsString
- Returns:
- The value as a String representation. Never
null.
-
isAscending
public boolean isAscending()- Specified by:
isAscendingin interfaceISortOrderIndicator- Returns:
trueis ascending sort order is active.
-
getAlternate
Get the alternate sort order. If the current sort order is ascending, the result will be descending and if this is descending, the return will be ascending.- Returns:
- Never
null.
-
getFromValueOrDefault
Get theESortOrdermatching the provided value, defaulting toDEFAULT.- Parameters:
nValue- The value to search for.- Returns:
- Never
null.
-
getFromValue
Get theESortOrdermatching the provided value, with a custom default.- Parameters:
nValue- The value to search for.eDefault- The default value to return if no match is found. May benull.- Returns:
- The matching enum value or the provided default.
-