U
- the unit for transformation reasonspublic abstract class Unit<U extends Unit<U>> extends Object implements Serializable
Copyright (c) 2015-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
$LastChangedDate: 2018-08-10 10:39:38 +0200 (Fri, 10 Aug 2018) $, @version $Revision: 287 $, by $Author: averbraeck $,
initial version May 15, 2014
Modifier and Type | Field and Description |
---|---|
static String[] |
STANDARD_UNITS
The array of the names of the standard units.
|
Modifier | Constructor and Description |
---|---|
protected |
Unit(String nameOrNameKey,
String abbreviationOrAbbreviationKey,
UnitSystem unitSystem,
boolean standardUnit)
Build a standard unit and create the fields for a unit.
|
protected |
Unit(String nameOrNameKey,
String abbreviationOrAbbreviationKey,
UnitSystem unitSystem,
Scale scale,
boolean standardUnit)
Build a unit with a specific conversion scale to/from the standard unit.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
abstract boolean |
equalsIgnoreNaming(Object obj)
Test if two units are the same, except for the name and abbreviation.
|
int |
generateHashCode()
Generate a hashCode for caching.
|
String |
getAbbreviation() |
String |
getAbbreviationKey()
This method returns the abbreviation key, or null in case the abbreviation is hard coded.
|
Set<Unit<U>> |
getAllUnitsOfThisType()
Return a copy of the set of all defined units for this unit type.
|
String |
getName() |
String |
getNameKey()
This method returns the name key, or null in case the name is hard coded.
|
Scale |
getScale() |
SICoefficients |
getSICoefficients() |
abstract String |
getSICoefficientsString() |
abstract U |
getStandardUnit() |
static <V extends Unit<V>> |
getUnits(Class<V> unitClass)
Return a set of defined units for a given unit type.
|
UnitSystem |
getUnitSystem() |
int |
hashCode() |
boolean |
isBaseSIUnit()
Determine whether this unit is the standard unit.
|
boolean |
isLocalizable()
Report if this unit support localization.
|
static SIUnit |
lookupOrCreateSIUnitWithSICoefficients(String normalizedSICoefficientsString) |
static Set<Unit<?>> |
lookupOrCreateUnitWithSICoefficients(String normalizedSICoefficientsString) |
static Set<Unit<?>> |
lookupUnitWithSICoefficients(String normalizedSICoefficientsString) |
String |
toString() |
public static final String[] STANDARD_UNITS
protected Unit(String nameOrNameKey, String abbreviationOrAbbreviationKey, UnitSystem unitSystem, boolean standardUnit)
nameOrNameKey
- if standardUnit: the key to the locale file for the long name of the unit, otherwise the name itselfabbreviationOrAbbreviationKey
- if standardUnit: the key to the locale file for the abbreviation of the unit,
otherwise the abbreviation itselfunitSystem
- the unit system, e.g. SI or ImperialstandardUnit
- indicates whether it is a standard unit with a definition in the locale, or a user-defined unitprotected Unit(String nameOrNameKey, String abbreviationOrAbbreviationKey, UnitSystem unitSystem, Scale scale, boolean standardUnit)
nameOrNameKey
- if standardUnit: the key to the locale file for the long name of the unit, otherwise the name itselfabbreviationOrAbbreviationKey
- if standardUnit: the key to the locale file for the abbreviation of the unit,
otherwise the abbreviation itselfunitSystem
- the unit system, e.g. SI or Imperialscale
- the conversion scale to use for this unitstandardUnit
- indicates whether it is a standard unit with a definition in the locale, or a user-defined unitpublic final boolean isLocalizable()
public static <V extends Unit<V>> Set<V> getUnits(Class<V> unitClass)
V
- the unit type to use in this method.unitClass
- the class for which the units are requested, e.g. ForceUnit.classpublic final Set<Unit<U>> getAllUnitsOfThisType()
public final String getName()
public final String getNameKey()
public final String getAbbreviation()
public final String getAbbreviationKey()
public Scale getScale()
public final UnitSystem getUnitSystem()
public abstract U getStandardUnit()
public abstract String getSICoefficientsString()
public final SICoefficients getSICoefficients()
public final boolean isBaseSIUnit()
public static Set<Unit<?>> lookupUnitWithSICoefficients(String normalizedSICoefficientsString)
normalizedSICoefficientsString
- the normalized string (e.g., kg.m/s2) to look uppublic static Set<Unit<?>> lookupOrCreateUnitWithSICoefficients(String normalizedSICoefficientsString)
normalizedSICoefficientsString
- the normalized string (e.g., kg.m/s2) to look uppublic static SIUnit lookupOrCreateSIUnitWithSICoefficients(String normalizedSICoefficientsString)
normalizedSICoefficientsString
- the normalized string (e.g., kg.m/s2) to look uppublic final int generateHashCode()
public abstract boolean equalsIgnoreNaming(Object obj)
obj
- the object to compare withCopyright © 2015–2018 Delft University of Technology. All rights reserved.