public final class ProductUnit<Q extends Quantity> extends DerivedUnit<Q>
This class represents units formed by the product of rational powers of existing units.
This class maintains the canonical form of this product (simplest
form after factorization). For example:
METER.pow(2).divide(METER)
returns
METER
.
Unit.times(Unit)
,
Unit.divide(Unit)
,
Unit.pow(int)
,
Unit.root(int)
,
Serialized FormConstructor and Description |
---|
ProductUnit(Unit<?> productUnit)
Copy constructor (allows for parameterization of product units).
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object that)
Indicates if this product unit is considered equals to the specified
object.
|
Unit<? super Q> |
getStandardUnit()
Returns the
base unit , alternate
unit or product of base units and alternate units this unit is derived
from. |
Unit<? extends Quantity> |
getUnit(int index)
Returns the unit at the specified position.
|
int |
getUnitCount()
Returns the number of units in this product.
|
int |
getUnitPow(int index)
Returns the power exponent of the unit at the specified position.
|
int |
getUnitRoot(int index)
Returns the root exponent of the unit at the specified position.
|
int |
hashCode()
Returns the hash code for this unit.
|
UnitConverter |
toStandardUnit()
Returns the converter from this unit to its system unit.
|
public ProductUnit(Unit<?> productUnit)
productUnit
- the product unit source.java.lang.ClassCastException
- if the specified unit is not
a product unit.public int getUnitCount()
public Unit<? extends Quantity> getUnit(int index)
index
- the index of the unit to return.java.lang.IndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= size())
.public int getUnitPow(int index)
index
- the index of the unit to return.java.lang.IndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= size())
.public int getUnitRoot(int index)
index
- the index of the unit to return.java.lang.IndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= size())
.public boolean equals(java.lang.Object that)
public int hashCode()
Unit
public Unit<? super Q> getStandardUnit()
Unit
base unit
, alternate
unit
or product of base units and alternate units this unit is derived
from. The standard unit identifies the "type" of
quantity
for which this unit is employed.
For example:[code]
boolean isAngularVelocity(Unit> u) {
return u.getStandardUnit().equals(RADIAN.divide(SECOND));
}
assert(REVOLUTION.divide(MINUTE).isAngularVelocity());
[/code]
Note: Having the same system unit is not sufficient to ensure that a converter exists between the two units (e.g. °C/m and K/m).
getStandardUnit
in class Unit<Q extends Quantity>
public UnitConverter toStandardUnit()
Unit
toStandardUnit
in class Unit<Q extends Quantity>
this.getConverterTo(this.getSystemUnit())