Q
- The type of the quantity measured by this unit.public final class ProductUnit<Q extends javax.measure.Quantity<Q>> extends AbstractUnit<Q>
This class represents units formed by the product of rational powers of existing physical units.
This class maintains the canonical form of this product (simplest form after factorization). For example: METRE.pow(2).divide(METRE)
returns METRE
.
Modifier and Type | Class and Description |
---|---|
private static class |
ProductUnit.Element
Inner product element represents a rational power of a single unit.
|
Modifier and Type | Field and Description |
---|---|
private ProductUnit.Element[] |
elements
Holds the units composing this product unit.
|
private static long |
serialVersionUID |
private java.lang.String |
symbol
Holds the symbol for this unit.
|
name, ONE, SYMBOL_TO_UNIT
Modifier | Constructor and Description |
---|---|
|
ProductUnit()
DefaultQuantityFactory constructor (used solely to create
ONE instance). |
private |
ProductUnit(ProductUnit.Element[] elements)
Product unit constructor.
|
|
ProductUnit(javax.measure.Unit<?> productUnit)
Copy constructor (allows for parameterization of product units).
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
private static int |
gcd(int m,
int n)
Returns the greatest common divisor (Euclid's algorithm).
|
java.util.Map<javax.measure.Unit<?>,java.lang.Integer> |
getBaseUnits() |
javax.measure.Dimension |
getDimension() |
private static javax.measure.Unit<?> |
getInstance(ProductUnit.Element[] leftElems,
ProductUnit.Element[] rightElems)
Returns the unit defined from the product of the specified elements.
|
(package private) static javax.measure.Unit<?> |
getPowInstance(AbstractUnit<?> unit,
int n)
Returns the product unit corresponding to this unit raised to the specified exponent.
|
static javax.measure.Unit<?> |
getProductInstance(javax.measure.Unit<?> left,
javax.measure.Unit<?> right)
Returns the product of the specified units.
|
static javax.measure.Unit<?> |
getQuotientInstance(javax.measure.Unit<?> left,
javax.measure.Unit<?> right)
Returns the quotient of the specified units.
|
static javax.measure.Unit<?> |
getRootInstance(AbstractUnit<?> unit,
int n)
Returns the product unit corresponding to the specified root of the specified unit.
|
java.lang.String |
getSymbol() |
javax.measure.UnitConverter |
getSystemConverter()
Returns the converter from this unit to its unscaled
System Unit unit. |
javax.measure.Unit<?> |
getUnit(int index)
Returns the unit element at the specified position.
|
int |
getUnitCount()
Returns the number of unit elements in this product.
|
int |
getUnitPow(int index)
Returns the power exponent of the unit element at the specified position.
|
int |
getUnitRoot(int index)
Returns the root exponent of the unit element at the specified position.
|
int |
hashCode() |
AbstractUnit<Q> |
toSystemUnit()
Returns the unscaled
SI unit from which this unit is derived. |
alternate, annotate, asType, compareTo, divide, divide, divide, getActualType, getConverterTo, getConverterToAny, getName, getSystemUnit, inverse, isCompatible, isSystemUnit, multiply, multiply, multiply, parse, pow, root, setName, setSymbol, shift, toString, transform
private static final long serialVersionUID
private final ProductUnit.Element[] elements
private final java.lang.String symbol
public ProductUnit()
ONE
instance).public ProductUnit(javax.measure.Unit<?> productUnit)
productUnit
- the product unit source.java.lang.ClassCastException
- if the specified unit is not a product unit.private ProductUnit(ProductUnit.Element[] elements)
elements
- the product elements.public static javax.measure.Unit<?> getProductInstance(javax.measure.Unit<?> left, javax.measure.Unit<?> right)
left
- the left unit operand.right
- the right unit operand.left * right
public static javax.measure.Unit<?> getQuotientInstance(javax.measure.Unit<?> left, javax.measure.Unit<?> right)
left
- the dividend unit operand.right
- the divisor unit operand.dividend / divisor
public static javax.measure.Unit<?> getRootInstance(AbstractUnit<?> unit, int n)
unit
- the unit.n
- the root's order (n > 0).unit^(1/nn)
java.lang.ArithmeticException
- if n == 0
.static javax.measure.Unit<?> getPowInstance(AbstractUnit<?> unit, int n)
unit
- the unit.nn
- the exponent (nn > 0).unit^n
public int getUnitCount()
public javax.measure.Unit<?> getUnit(int index)
index
- the index of the unit element to return.java.lang.IndexOutOfBoundsException
- if index is out of range (index < 0 || index >= getUnitCount())
.public int getUnitPow(int index)
index
- the index of the unit element.java.lang.IndexOutOfBoundsException
- if index is out of range (index < 0 || index >= getUnitCount())
.public int getUnitRoot(int index)
index
- the index of the unit element.java.lang.IndexOutOfBoundsException
- if index is out of range (index < 0 || index >= getUnitCount())
.public java.util.Map<javax.measure.Unit<?>,java.lang.Integer> getBaseUnits()
getBaseUnits
in interface javax.measure.Unit<Q extends javax.measure.Quantity<Q>>
getBaseUnits
in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
public boolean equals(java.lang.Object obj)
equals
in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
public int hashCode()
hashCode
in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
public AbstractUnit<Q> toSystemUnit()
AbstractUnit
SI
unit from which this unit is derived.
They SI unit can be be used to identify a quantity given the unit. For example:[code] static boolean isAngularVelocity(AbstractUnit> unit) {
return unit.toSI().equals(RADIAN.divide(SECOND)); } assert(REVOLUTION.divide(MINUTE).isAngularVelocity()); // Returns true. [/code]toSystemUnit
in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
public javax.measure.UnitConverter getSystemConverter()
AbstractUnit
System Unit
unit.getSystemConverter
in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
getConverterTo(this.toSystemUnit())
#toSI
public javax.measure.Dimension getDimension()
getDimension
in interface javax.measure.Unit<Q extends javax.measure.Quantity<Q>>
getDimension
in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
private static javax.measure.Unit<?> getInstance(ProductUnit.Element[] leftElems, ProductUnit.Element[] rightElems)
leftElems
- left multiplicand elements.rightElems
- right multiplicand elements.private static int gcd(int m, int n)
m
- the first number.nn
- the second number.