org.elasticsearch.common.unit
Enum DistanceUnit
java.lang.Object
java.lang.Enum<DistanceUnit>
org.elasticsearch.common.unit.DistanceUnit
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable<DistanceUnit>
public enum DistanceUnit
- extends java.lang.Enum<DistanceUnit>
Methods inherited from class java.lang.Enum |
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
MILES
public static final DistanceUnit MILES
KILOMETERS
public static final DistanceUnit KILOMETERS
earthCircumference
protected final double earthCircumference
earthRadius
protected final double earthRadius
distancePerDegree
protected final double distancePerDegree
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(java.lang.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:
java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified name
java.lang.NullPointerException
- if the argument is null
convert
public static double convert(double distance,
DistanceUnit from,
DistanceUnit to)
- Converts the given distance from the given DistanceUnit, to the given DistanceUnit
- 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 uni
parse
public static double parse(java.lang.String distance,
DistanceUnit defaultUnit,
DistanceUnit to)
parseUnit
public static DistanceUnit parseUnit(java.lang.String distance,
DistanceUnit defaultUnit)
getEarthCircumference
public double getEarthCircumference()
getEarthRadius
public double getEarthRadius()
getDistancePerDegree
public double getDistancePerDegree()
toMiles
public abstract double toMiles(double distance)
toKilometers
public abstract double toKilometers(double distance)
toString
public abstract java.lang.String toString(double distance)
fromString
public static DistanceUnit fromString(java.lang.String unit)
writeDistanceUnit
public static void writeDistanceUnit(StreamOutput out,
DistanceUnit unit)
throws java.io.IOException
- Throws:
java.io.IOException
readDistanceUnit
public static DistanceUnit readDistanceUnit(StreamInput in)
throws java.io.IOException
- Throws:
java.io.IOException