Package org.cyclos.model.utils
Enum DistanceUnit
- java.lang.Object
-
- java.lang.Enum<DistanceUnit>
-
- org.cyclos.model.utils.DistanceUnit
-
- All Implemented Interfaces:
Serializable,Comparable<DistanceUnit>,HasMessageKey
public enum DistanceUnit extends Enum<DistanceUnit> implements HasMessageKey
Represents a distance unit
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doublefromMeters(double meters)Converts a given meters value into this unitBigDecimalgetDefaultValue()Returns the value which can be initially selectedMessageKeygetMessageKey()static List<BigDecimal>getValues(DistanceUnit distanceUnit)Returns the values available for the given distance unitstatic EnumMessageKeyResolver<DistanceUnit>resolverForDistanceFrom()Returns anEnumMessageKeyResolverfor translations to display a distance from another pointstatic EnumMessageKeyResolver<DistanceUnit>resolverForDistanceWithUnit()Returns anEnumMessageKeyResolverfor translations to display a distance amount together with its unitdoubletoMeters(double value)Converts a given value to metersstatic DistanceUnitvalueOf(String name)Returns the enum constant of this type with the specified name.static DistanceUnit[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
KILOMETER
public static final DistanceUnit KILOMETER
-
MILE
public static final DistanceUnit MILE
-
-
Method Detail
-
values
public static DistanceUnit[] 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 (DistanceUnit c : DistanceUnit.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static DistanceUnit 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
-
getValues
public static List<BigDecimal> getValues(DistanceUnit distanceUnit)
Returns the values available for the given distance unit
-
resolverForDistanceFrom
public static EnumMessageKeyResolver<DistanceUnit> resolverForDistanceFrom()
Returns anEnumMessageKeyResolverfor translations to display a distance from another point
-
resolverForDistanceWithUnit
public static EnumMessageKeyResolver<DistanceUnit> resolverForDistanceWithUnit()
Returns anEnumMessageKeyResolverfor translations to display a distance amount together with its unit
-
fromMeters
public double fromMeters(double meters)
Converts a given meters value into this unit
-
getDefaultValue
public BigDecimal getDefaultValue()
Returns the value which can be initially selected
-
getMessageKey
public MessageKey getMessageKey()
- Specified by:
getMessageKeyin interfaceHasMessageKey
-
toMeters
public double toMeters(double value)
Converts a given value to meters
-
-