Package ucar.units
Class Factor
- java.lang.Object
-
- ucar.units.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
Indicates if this Factor is semantically identical to another object.Base
getBase()
Returns the Base entity.int
getExponent()
Returns the exponent of the Base entity.String
getID()
Returns the identifier of the Base entity.int
hashCode()
Returns the hash code of this instance.boolean
isDimensionless()
Indicates if this factor is dimensionless.boolean
isReciprocalOf(Factor that)
Indicates if this Factor is the reciprocal of another Factor.Factor
pow(int power)
Raises this Factor to a power.String
toString()
Returns the string representation of this Factor.
-
-
-
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.
-
equals
public boolean equals(Object object)
Indicates if this Factor is semantically identical to another object.
-
hashCode
public int hashCode()
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 ofthat
.
-
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.
-
-