Package ucar.units

Class Factor

  • All Implemented Interfaces:
    Serializable

    @Immutable
    public final class Factor
    extends Object
    implements Serializable
    Provides support for a Base/exponent pair. Instances of this class are immutable.
    See Also:
    Serialized Form
    • Constructor Detail

      • Factor

        public Factor​(Base base)
        Constructs from a Base. The exponent is set to unity.
        Parameters:
        base - The base entity.
      • Factor

        public Factor​(Factor factor,
                      int exponent)
        Constructs from a Factor and an exponent.
        Parameters:
        factor - The factor.
        exponent - The exponent.
      • Factor

        public Factor​(Base base,
                      int exponent)
        Constructs from a Base and an exponent.
        Parameters:
        base - The base entity.
        exponent - The exponent.
    • Method Detail

      • getBase

        public Base getBase()
        Returns the Base entity.
        Returns:
        The Base entity.
      • getID

        public String getID()
        Returns the identifier of the Base entity.
        Returns:
        The identifier of the Base entity (symbol or name).
      • getExponent

        public int getExponent()
        Returns the exponent of the Base entity.
        Returns:
        The exponent of the Base entity.
      • pow

        public Factor pow​(int power)
        Raises this Factor to a power.
        Parameters:
        power - The power by which to raise this Factor.
        Returns:
        The Factor resulting from raising this Factor to the given power.
      • toString

        public final String toString()
        Returns the string representation of this Factor.
        Overrides:
        toString in class Object
        Returns:
        The string representation of this Factor.
      • equals

        public boolean equals​(Object object)
        Indicates if this Factor is semantically identical to another object.
        Overrides:
        equals in class Object
        Parameters:
        object - The object.
        Returns:
        true if and only if this Factor is semantically identical to object< /code>.
      • hashCode

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

        public boolean isReciprocalOf​(Factor that)
        Indicates if this Factor is the reciprocal of another Factor.
        Parameters:
        that - The other factor.
        Returns:
        true if and only if this Factor is the reciprocal of that.
      • isDimensionless

        public boolean isDimensionless()
        Indicates if this factor is dimensionless. A Factor is dimensionless if and only if the exponent is zero or the Base entity is dimensionless.
        Returns:
        true if and only if this Factor is dimensionless.