Package ucar.units
Class UnitName
- java.lang.Object
-
- ucar.units.UnitID
-
- ucar.units.UnitName
-
- All Implemented Interfaces:
Serializable
,Comparable<Object>
public final class UnitName extends UnitID implements Comparable<Object>
Provides support for unit names.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Object object)
Compares this UnitName with another UnitName.boolean
equals(Object object)
Indicates if this UnitName is semantically identical to an object.String
getName()
Returns the name.String
getPlural()
Returns the plural form of the unit name.String
getSymbol()
Returns the symbol.int
hashCode()
Returns the hash code of this instance.protected String
makePlural(String name)
Returns the plural form of a name.static UnitName
newUnitName(String name)
Factory method for constructing a UnitName from a name.static UnitName
newUnitName(String name, String plural)
Factory method for constructing a UnitName from a name and a plural form of the name.static UnitName
newUnitName(String name, String plural, String symbol)
Factory method for constructing a UnitName from a name, a plural form of the name, and a symbol.String
toString()
Returns the string representation of this identifier.
-
-
-
Constructor Detail
-
UnitName
protected UnitName(String name, String symbol) throws NameException
Constructs from a name and a symbol. Regular rules are use to construct the plural form of the unit name.- Parameters:
name
- The name of the unit. Shall not benull
.symbol
- The symbol for the unit. May benull
.- Throws:
NameException
-name == null
.
-
UnitName
protected UnitName(String name, String plural, String symbol) throws NameException
Constructs from a name, a plural form of the unit name, and a symbol.- Parameters:
name
- The name of the unit. Shall not benull
.plural
- The plural form of the name. May benull
, in which case regular plural- forming rules are used to construct the plural form from the name.symbol
- The symbol for the unit. May benull
.- Throws:
NameException
-name == null
.
-
-
Method Detail
-
newUnitName
public static UnitName newUnitName(String name) throws NameException
Factory method for constructing a UnitName from a name.- Parameters:
name
- The name of the unit. Shall not benull
.- Throws:
NameException
-name == null
.
-
newUnitName
public static UnitName newUnitName(String name, String plural) throws NameException
Factory method for constructing a UnitName from a name and a plural form of the name.- Parameters:
name
- The name of the unit. Shall not benull
.plural
- The plural form of the name. May benull
, in which case regular plural- forming rules are used to construct the plural form from the name.- Throws:
NameException
-name == null
.
-
newUnitName
public static UnitName newUnitName(String name, String plural, String symbol) throws NameException
Factory method for constructing a UnitName from a name, a plural form of the name, and a symbol.- Parameters:
name
- The name of the unit. Shall not benull
.plural
- The plural form of the name. May benull
, in which case regular plural- forming rules are used to construct the plural form from the name.symbol
- The symbol for the unit. May benull
.- Throws:
NameException
-name == null
.
-
getName
public final String getName()
Returns the name.
-
getPlural
public String getPlural()
Returns the plural form of the unit name.
-
getSymbol
public final String getSymbol()
Returns the symbol.
-
toString
public final String toString()
Returns the string representation of this identifier.
-
compareTo
public final int compareTo(Object object)
Compares this UnitName with another UnitName.- Specified by:
compareTo
in interfaceComparable<Object>
-
equals
public final boolean equals(Object object)
Indicates if this UnitName is semantically identical to an object.
-
hashCode
public int hashCode()
Returns the hash code of this instance.
-
-