com.here.msdkui.common.measurements

## Class Converter

- java.lang.Object
- - com.here.msdkui.common.measurements.Converter

- Direct Known Subclasses:
    LengthConverter, SpeedConverter

      public abstract class Converter
      extends java.lang.Object

  Base class for unit converters.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static double` | `KILOMETER_IN_METERS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Converter()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Measurement` | `convert(double in, MeasurementUnit from, MeasurementUnit to)` Converts a value in given `MeasurementUnit` to another unit.
    `protected abstract double` | `fromBaseTo(double in, MeasurementUnit unit)` Converts a value from base unit to unit of the given type.
    `protected static boolean` | `isLength(MeasurementUnit unit)`
    `protected static boolean` | `isMetric(MeasurementUnit unit)`
    `protected static boolean` | `isSpeed(MeasurementUnit unit)`
    `static double` | `round(double value, int places)` Round a given value to the number of decimal places.
    `protected abstract double` | `toBaseUnit(double in, MeasurementUnit unit)` Converts a value of given unit to the base unit.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### KILOMETER_IN_METERS

          protected static final double KILOMETER_IN_METERS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Converter

          public Converter()

  - ### Method Detail

    - #### convert

          public Measurement convert(double in,
                                     MeasurementUnit from,
                                     MeasurementUnit to)

      Converts a value in given `MeasurementUnit` to another unit.
      Parameters:
        `in` - a value to be converted.
        `from` - a source `MeasurementUnit`.
        `to` - a target `MeasurementUnit`.
      Returns:
        results of conversion as instance of `Measurement`.

    - #### toBaseUnit

          protected abstract double toBaseUnit(double in,
                                               MeasurementUnit unit)

      Converts a value of given unit to the base unit.
      Parameters:
        `in` - a value to be converted.
        `unit` - a `MeasurementUnit` to be converted to base.
      Returns:
        converted value.

    - #### fromBaseTo

          protected abstract double fromBaseTo(double in,
                                               MeasurementUnit unit)

      Converts a value from base unit to unit of the given type.
      Parameters:
        `in` - a value to be converted.
        `unit` - a target `MeasurementUnit`.
      Returns:
        converted value.

    - #### round

          public static double round(double value,
                                     int places)

      Round a given value to the number of decimal places.
      Parameters:
        `value` - value to round.
        `places` - number of decimal places.
      Returns:
        a rounded value.

    - #### isSpeed

          protected static boolean isSpeed(MeasurementUnit unit)

    - #### isLength

          protected static boolean isLength(MeasurementUnit unit)

    - #### isMetric

          protected static boolean isMetric(MeasurementUnit unit)