Package com.helger.commons.compare
Enum ESortOrder
- java.lang.Object
-
- java.lang.Enum<ESortOrder>
-
- com.helger.commons.compare.ESortOrder
-
- All Implemented Interfaces:
ISortOrderIndicator,Serializable,Comparable<ESortOrder>
public enum ESortOrder extends Enum<ESortOrder> implements ISortOrderIndicator
Defines possible sort orders. The default isASCENDINGsorting.- Author:
- Philip Helger
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ASCENDINGDESCENDING
-
Field Summary
Fields Modifier and Type Field Description static ESortOrderDEFAULTThe default sort order isASCENDING
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ESortOrdergetAlternate()Get the alternate sort order.static ESortOrdergetFromValue(int nValue, ESortOrder eDefault)static ESortOrdergetFromValueOrDefault(int nValue)intgetValue()StringgetValueAsString()booleanisAscending()static ESortOrdervalueOf(String name)Returns the enum constant of this type with the specified name.static ESortOrder[]values()Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface com.helger.commons.compare.ISortOrderIndicator
isDescending
-
-
-
-
Enum Constant Detail
-
ASCENDING
public static final ESortOrder ASCENDING
-
DESCENDING
public static final ESortOrder DESCENDING
-
-
Field Detail
-
DEFAULT
public static final ESortOrder DEFAULT
The default sort order isASCENDING
-
-
Method Detail
-
values
public static ESortOrder[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ESortOrder c : ESortOrder.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ESortOrder valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type 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.
-
isAscending
public boolean isAscending()
- Specified by:
isAscendingin interfaceISortOrderIndicator- Returns:
trueis ascending sort order is active.
-
getAlternate
@Nonnull public ESortOrder 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
@Nonnull public static ESortOrder getFromValueOrDefault(int nValue)
-
getFromValue
@Nullable public static ESortOrder getFromValue(int nValue, @Nullable ESortOrder eDefault)
-
-