de.caff.util.measure

## Class LengthUnit

- java.lang.Object
- - de.caff.util.measure.LengthUnit

- All Implemented Interfaces:
    java.io.Serializable

      public final class LengthUnit
      extends java.lang.Object
      implements java.io.Serializable

  A physical length unit.
  Author:
    Rammi
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static LengthUnit` | `ANGSTROM` The Angstrom unit.
    `static LengthUnit` | `ASTRONOMICAL_UNIT` The Astronomical Unit.
    `static LengthUnit` | `CENTIMETER` The CENTIMETER unit.
    `static LengthUnit` | `DECIMETER` The DECIMETER unit.
    `static LengthUnit` | `FOOT` The FOOT unit.
    `static LengthUnit` | `INCH` The INCH unit.
    `static LengthUnit` | `KILOMETER` The KILOMETER unit.
    `static LengthUnit` | `LIGHTYEAR` The light year.
    `static LengthUnit` | `METER` The METER unit.
    `static LengthUnit` | `MICROMETER` The MICROMETER unit.
    `static LengthUnit` | `MILE` The statute MILE unit.
    `static LengthUnit` | `MILLIMETER` The MILLIMETER unit.
    `static LengthUnit` | `NANOMETER` The NANOMETER unit.
    `static LengthUnit` | `PARSEC` The parsec.
    `static LengthUnit` | `PICA_POINT` The printers point, as in England and USA.
    `static LengthUnit` | `PICOMETER` The PICOMETER unit.
    `static LengthUnit` | `POINT` The POINT unit.
    `static LengthUnit` | `YARD` The YARD unit.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LengthUnit(double metersPerUnit, java.lang.String unitName, java.lang.String unitShortCut)` Construct a length unit with the given unit/meter ratio, name and shortcut.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object obj)` Compare to another unit.
    `static LengthUnit` | `getLengthUnit(java.lang.String unitShortcut)` Get the length unit for a given unit shortcut.
    `java.lang.String` | `getName()` Return the name.
    `java.lang.String` | `getShortCut()` Return the shortcut.
    `int` | `hashCode()` Provide a useful hash code.
    `PhysicalLength` | `length(double length)` Get a length using this unit.
    `double` | `meterToUnit(double meter)` Transform the given length in meters to this unit.
    `double` | `otherToUnit(double length, LengthUnit other)` Transform the given length from arbitrary units to this units.
    `java.lang.String` | `toString()` Return a string representation.
    `double` | `unitToMeter(double units)` Transform the given length in units to meter.

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### METER

          public static final LengthUnit METER

      The METER unit.

    - #### KILOMETER

          public static final LengthUnit KILOMETER

      The KILOMETER unit.

    - #### DECIMETER

          public static final LengthUnit DECIMETER

      The DECIMETER unit.

    - #### CENTIMETER

          public static final LengthUnit CENTIMETER

      The CENTIMETER unit.

    - #### MILLIMETER

          public static final LengthUnit MILLIMETER

      The MILLIMETER unit.

    - #### MICROMETER

          public static final LengthUnit MICROMETER

      The MICROMETER unit.

    - #### NANOMETER

          public static final LengthUnit NANOMETER

      The NANOMETER unit.

    - #### PICOMETER

          public static final LengthUnit PICOMETER

      The PICOMETER unit.

    - #### ANGSTROM

          public static final LengthUnit ANGSTROM

      The Angstrom unit.

    - #### ASTRONOMICAL_UNIT

          public static final LengthUnit ASTRONOMICAL_UNIT

      The Astronomical Unit.

    - #### LIGHTYEAR

          public static final LengthUnit LIGHTYEAR

      The light year.

    - #### PARSEC

          public static final LengthUnit PARSEC

      The parsec.

    - #### INCH

          public static final LengthUnit INCH

      The INCH unit.

    - #### FOOT

          public static final LengthUnit FOOT

      The FOOT unit.

    - #### YARD

          public static final LengthUnit YARD

      The YARD unit.

    - #### MILE

          public static final LengthUnit MILE

      The statute MILE unit.

    - #### POINT

          public static final LengthUnit POINT

      The POINT unit.

    - #### PICA_POINT

          public static final LengthUnit PICA_POINT

      The printers point, as in England and USA.

  - ### Constructor Detail

    - #### LengthUnit

          public LengthUnit(double metersPerUnit,
                            @NotNull
                            java.lang.String unitName,
                            @NotNull
                            java.lang.String unitShortCut)

      Construct a length unit with the given unit/meter ratio, name and shortcut.
      Parameters:
        `metersPerUnit` - the ratio `unit/m`
        `unitName` - the name of the unit
        `unitShortCut` - the standard shortcut for the unit

  - ### Method Detail

    - #### getShortCut

          @NotNull
          public java.lang.String getShortCut()

      Return the shortcut.
      Returns:
        the unit's shortcut

    - #### getName

          @NotNull
          public java.lang.String getName()

      Return the name.
      Returns:
        the unit's name

    - #### toString

          public java.lang.String toString()

      Return a string representation.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        the shortcut

    - #### meterToUnit

          public double meterToUnit(double meter)

      Transform the given length in meters to this unit.
      Parameters:
        `meter` - length (in meter)
      Returns:
        length (in units)

    - #### unitToMeter

          public double unitToMeter(double units)

      Transform the given length in units to meter.
      Parameters:
        `units` - length (in units)
      Returns:
        length (in meter)

    - #### otherToUnit

          public double otherToUnit(double length,
                                    @NotNull
                                    LengthUnit other)

      Transform the given length from arbitrary units to this units.
      Parameters:
        `length` - length in given units
        `other` - (other) unit of length
      Returns:
        length (in this unit)

    - #### equals

          public boolean equals(java.lang.Object obj)

      Compare to another unit.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `obj` - other unit
      Returns:
        `true` if both units are equal.

    - #### hashCode

          public int hashCode()

      Provide a useful hash code.
      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        hash code

    - #### length

          @NotNull
          public PhysicalLength length(double length)

      Get a length using this unit.
      Parameters:
        `length` - length
      Returns:
        physical length using this unit

    - #### getLengthUnit

          @Nullable
          public static LengthUnit getLengthUnit(@Nullable
                                                           java.lang.String unitShortcut)

      Get the length unit for a given unit shortcut.
      Parameters:
        `unitShortcut` - unit shortcut (eg `mm` or `in`)
      Returns:
        matching unit or `null`