Package ucar.units

Class UnitName

    • 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 be null.
        symbol - The symbol for the unit. May be null .
        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 be null.
        plural - The plural form of the name. May be null, in which case regular plural- forming rules are used to construct the plural form from the name.
        symbol - The symbol for the unit. May be null .
        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 be null.
        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 be null.
        plural - The plural form of the name. May be null, 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 be null.
        plural - The plural form of the name. May be null, in which case regular plural- forming rules are used to construct the plural form from the name.
        symbol - The symbol for the unit. May be null .
        Throws:
        NameException - name == null.
      • getName

        public final String getName()
        Returns the name.
        Specified by:
        getName in class UnitID
        Returns:
        The name. Won't be null.
      • getPlural

        public String getPlural()
        Returns the plural form of the unit name.
        Specified by:
        getPlural in class UnitID
        Returns:
        The plural form of the unit name.
      • getSymbol

        public final String getSymbol()
        Returns the symbol.
        Specified by:
        getSymbol in class UnitID
        Returns:
        The symbol. Might be null.
      • toString

        public final String toString()
        Returns the string representation of this identifier.
        Specified by:
        toString in class UnitID
        Returns:
        The string representation of this identifier.
      • compareTo

        public final int compareTo​(Object object)
        Compares this UnitName with another UnitName.
        Specified by:
        compareTo in interface Comparable<Object>
      • equals

        public final boolean equals​(Object object)
        Indicates if this UnitName is semantically identical to an object.
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Returns the hash code of this instance.
        Overrides:
        hashCode in class Object
        Returns:
        The hash code of this instance.
      • makePlural

        protected String makePlural​(String name)
        Returns the plural form of a name. Regular rules are used to generate the plural form.
        Parameters:
        name - The name.
        Returns:
        The plural form of the name.