Enum Class ESDistanceUnit
- All Implemented Interfaces:
Serializable,Comparable<ESDistanceUnit>,Constable
The ESDistanceUnit enumerates several units for measuring distances. These units
provide methods for converting strings and methods to convert units among each
others. Some methods like
refer to
the earth ellipsoid defined in
invalid reference
ESDistanceUnit#getEarthCircumference
GeoUtils. The default unit used within
this project is METERS which is defined by DEFAULT-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class implements a value+unit tuple.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondoubleconvert(double distance, ESDistanceUnit unit) Convert a given value into another unitstatic doubleconvert(double distance, ESDistanceUnit from, ESDistanceUnit to) Converts the given distance from the given ESDistanceUnit, to the given ESDistanceUnitdoublefromMeters(double distance) Convert a value given in meters to a value of this unitstatic ESDistanceUnitfromString(String unit) Convert a String to aESDistanceUnitdoubleparse(String distance, ESDistanceUnit defaultUnit) Parses a given distance and converts it to this unit.static doubleparse(String distance, ESDistanceUnit defaultUnit, ESDistanceUnit to) Parses a given distance and converts it to the specified unit.static ESDistanceUnitparseUnit(String distance, ESDistanceUnit defaultUnit) Parses the suffix of a given distance string and return the correspondingESDistanceUnitdoubletoMeters(double distance) Convert a value into meterstoString()toString(double distance) Convert a value to a distance stringstatic ESDistanceUnitReturns the enum constant of this class with the specified name.static ESDistanceUnit[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INCH
-
YARD
-
FEET
-
KILOMETERS
-
NAUTICALMILES
-
MILLIMETERS
-
CENTIMETERS
-
MILES
-
METERS
-
-
Field Details
-
DEFAULT
-
-
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
-
toMeters
public double toMeters(double distance) Convert a value into meters- Parameters:
distance- distance in this unit- Returns:
- value in meters
-
fromMeters
public double fromMeters(double distance) Convert a value given in meters to a value of this unit- Parameters:
distance- distance in meters- Returns:
- value in this unit
-
convert
Convert a given value into another unit- Parameters:
distance- value in this unitunit- source unit- Returns:
- value in this unit
-
toString
Convert a value to a distance string- Parameters:
distance- value to convert- Returns:
- String representation of the distance
-
toString
- Overrides:
toStringin classEnum<ESDistanceUnit>
-
convert
Converts the given distance from the given ESDistanceUnit, to the given ESDistanceUnit- Parameters:
distance- Distance to convertfrom- Unit to convert the distance fromto- Unit of distance to convert to- Returns:
- Given distance converted to the distance in the given unit
-
parse
Parses a given distance and converts it to the specified unit.- Parameters:
distance- String defining a distance (value and unit)defaultUnit- unit assumed if none is definedto- unit of result- Returns:
- parsed distance
-
parse
Parses a given distance and converts it to this unit.- Parameters:
distance- String defining a distance (value and unit)defaultUnit- unit to expect if none if provided- Returns:
- parsed distance
-
fromString
Convert a String to aESDistanceUnit- Parameters:
unit- name of the unit- Returns:
- unit matching the given name
- Throws:
IllegalArgumentException- if no unit matches the given name
-
parseUnit
Parses the suffix of a given distance string and return the correspondingESDistanceUnit- Parameters:
distance- string representing a distancedefaultUnit- default unit to use, if no unit is provided by the string- Returns:
- unit of the given distance
-