Enum RangingUnit
- All Implemented Interfaces:
Comparable<RangingUnit>
The unit a distance is read in.
There is deliberately no zero-argument distance getter on
RangingUpdate: the caller always names the unit. Both platforms report
meters natively, so a bare getDistance() would have been correct on
every device and still wrong in every app that displayed it as feet.
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionCentimeters.International feet, 0.3048 m exactly.International inches, 0.0254 m exactly.Meters, the unit both platforms measure in. -
Method Summary
Modifier and TypeMethodDescriptiondoublefromMeters(double meters) Converts a distance expressed in meters into this unit.doubletoMeters(double value) Converts a distance expressed in this unit into meters.static RangingUnitReturns the enum constant of this type with the specified name.static RangingUnit[]values()Returns an array containing the constants of this enum type, in the order they are declared.Methods inherited from class Enum
clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name, ordinal, setEnumValues, toString, valueOf
-
Enum Constant Details
-
METERS
Meters, the unit both platforms measure in. -
FEET
International feet, 0.3048 m exactly. -
CENTIMETERS
Centimeters. -
INCHES
International inches, 0.0254 m exactly.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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
-
fromMeters
public double fromMeters(double meters) Converts a distance expressed in meters into this unit.
Parameters
meters: the distance in meters
Returns
the same distance expressed in this unit
-
toMeters
public double toMeters(double value) Converts a distance expressed in this unit into meters.
Parameters
value: the distance in this unit
Returns
the same distance in meters
-