U
- the unit for transformation reasonspublic abstract class Unit<U extends Unit<U>> extends Object implements Serializable
Copyright (c) 2015-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
$LastChangedDate: 2019-03-03 00:53:50 +0100 (Sun, 03 Mar 2019) $, @version $Revision: 349 $, 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 name,
String abbreviation,
UnitSystem unitSystem)
Build a user-defined unit and create the fields for that unit.
|
protected |
Unit(String name,
String abbreviation,
UnitSystem unitSystem,
Scale scale)
Build a user-defined unit with a specific conversion scale to/from the standard unit.
|
protected |
Unit(String abbreviationKey,
UnitSystem unitSystem)
Build a standard unit and create the fields for that unit.
|
protected |
Unit(String abbreviationKey,
UnitSystem unitSystem,
Scale scale)
Build a standard 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 |
getDefaultLocaleAbbreviation() |
String |
getDefaultLocaleName() |
String |
getDefaultLocaleTextualRepresentation() |
List<String> |
getDefaultLocaleTextualRepresentations() |
String |
getDefaultTextualRepresentation() |
String |
getName() |
Scale |
getScale() |
SICoefficients |
getSICoefficients() |
abstract String |
getSICoefficientsString() |
abstract U |
getStandardUnit() |
List<String> |
getTextualRepresentations() |
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 abbreviationKey, UnitSystem unitSystem)
abbreviationKey
- String; the key to the locale file for the abbreviation of the unitunitSystem
- UnitSystem; the unit system, e.g. SI or Imperialprotected Unit(String abbreviationKey, UnitSystem unitSystem, Scale scale)
abbreviationKey
- String; the key to the locale file for the abbreviation of the unit, otherwise the abbreviation
itselfunitSystem
- UnitSystem; the unit system, e.g. SI or Imperialscale
- Scale; the conversion scale to use for this unitprotected Unit(String name, String abbreviation, UnitSystem unitSystem)
name
- String; the key to the locale file for the long name of the unit, otherwise the name itselfabbreviation
- String; the key to the locale file for the abbreviation of the unit, otherwise the abbreviation
itselfunitSystem
- UnitSystem; the unit system, e.g. SI or Imperialprotected Unit(String name, String abbreviation, UnitSystem unitSystem, Scale scale)
name
- String; the key to the locale file for the long name of the unit, otherwise the name itselfabbreviation
- String; the key to the locale file for the abbreviation of the unit, otherwise the abbreviation
itselfunitSystem
- UnitSystem; the unit system, e.g. SI or Imperialscale
- Scale; the conversion scale to use for this 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
- Class<V>; the class for which the units are requested, e.g. ForceUnit.classpublic final Set<Unit<U>> getAllUnitsOfThisType()
public final String getName()
public final String getDefaultLocaleName()
public final String getAbbreviation()
public final String getDefaultLocaleAbbreviation()
public final String getAbbreviationKey()
public final List<String> getTextualRepresentations()
public final List<String> getDefaultLocaleTextualRepresentations()
public final String getDefaultTextualRepresentation()
public final String getDefaultLocaleTextualRepresentation()
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
- String; 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
- String; the normalized string (e.g., kg.m/s2) to look uppublic final int generateHashCode()
public abstract boolean equalsIgnoreNaming(Object obj)
obj
- Object; the object to compare withCopyright © 2015–2019 Delft University of Technology. All rights reserved.