public final class LengthUnit
extends java.lang.Object
implements java.io.Serializable
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 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.
|
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.
|
public static final LengthUnit METER
public static final LengthUnit KILOMETER
public static final LengthUnit DECIMETER
public static final LengthUnit CENTIMETER
public static final LengthUnit MILLIMETER
public static final LengthUnit MICROMETER
public static final LengthUnit NANOMETER
public static final LengthUnit PICOMETER
public static final LengthUnit ANGSTROM
public static final LengthUnit ASTRONOMICAL_UNIT
public static final LengthUnit LIGHTYEAR
public static final LengthUnit PARSEC
public static final LengthUnit INCH
public static final LengthUnit FOOT
public static final LengthUnit YARD
public static final LengthUnit MILE
public static final LengthUnit POINT
public static final LengthUnit PICA_POINT
public LengthUnit(double metersPerUnit, @NotNull java.lang.String unitName, @NotNull java.lang.String unitShortCut)
metersPerUnit
- the ratio unit/munitName
- the name of the unitunitShortCut
- the standard shortcut for the unit@NotNull public java.lang.String getShortCut()
@NotNull public java.lang.String getName()
public java.lang.String toString()
toString
in class java.lang.Object
public double meterToUnit(double meter)
meter
- length (in meter)public double unitToMeter(double units)
units
- length (in units)public double otherToUnit(double length, @NotNull LengthUnit other)
length
- length in given unitsother
- (other) unit of lengthpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- other unittrue
if both units are equal.public int hashCode()
hashCode
in class java.lang.Object
@NotNull public PhysicalLength length(double length)
length
- length@Nullable public static LengthUnit getLengthUnit(@Nullable java.lang.String unitShortcut)
unitShortcut
- unit shortcut (eg mm or in)null