Enum RangingUnit

java.lang.Object
java.lang.Enum<RangingUnit>
com.codename1.nearby.ranging.RangingUnit
All Implemented Interfaces:
Comparable<RangingUnit>

public enum RangingUnit extends Enum<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 Details

    • METERS

      public static final RangingUnit METERS
      Meters, the unit both platforms measure in.
    • FEET

      public static final RangingUnit FEET
      International feet, 0.3048 m exactly.
    • CENTIMETERS

      public static final RangingUnit CENTIMETERS
      Centimeters.
    • INCHES

      public static final RangingUnit INCHES
      International inches, 0.0254 m exactly.
  • Method Details

    • values

      public static RangingUnit[] 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

      public static RangingUnit 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 name
      NullPointerException - 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