JSR-275 - Measurements and Units Specification

javax.measure.unit
Class CompoundUnit<Q extends Quantity>

java.lang.Object
  extended by javax.measure.unit.Unit<Q>
      extended by javax.measure.unit.DerivedUnit<Q>
          extended by javax.measure.unit.CompoundUnit<Q>
All Implemented Interfaces:
java.io.Serializable

public final class CompoundUnit<Q extends Quantity>
extends DerivedUnit<Q>

This class represents the multi-radix units (such as "hour:min:sec"). Instances of this class are created using the Unit.compound method.

Examples of compound units:

     Unit<Duration> HOUR_MINUTE_SECOND = HOUR.compound(MINUTE).compound(SECOND);
     Unit<Angle> DEGREE_MINUTE_ANGLE = DEGREE_ANGLE.compound(MINUTE_ANGLE);
     

Version:
3.1, April 22, 2006
Author:
Jean-Marie Dautelle
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.measure.unit.Unit
ONE
 
Method Summary
 boolean equals(java.lang.Object that)
          Indicates if this compound unit is considered equals to the specified object (both are compound units with same composing units in the same order).
 Unit<Q> getFirst()
          Returns the first unit of this compound unit (never a compound unit)
 Unit<Q> getNext()
          Returns the next unit(s) of this compound unit (can be a compound unit).
 Unit<? super Q> getSystemUnit()
          Returns the base unit, alternate unit or product of base units and alternate units this unit is derived from.
 int hashCode()
          Returns the hash code for this unit.
 UnitConverter toSystemUnit()
          Returns the converter from this unit to its system unit.
 
Methods inherited from class javax.measure.unit.Unit
asType, compound, divide, divide, divide, getConverterTo, getDimension, inverse, isCompatible, plus, pow, root, times, times, times, toString, transform, valueOf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getFirst

public Unit<Q> getFirst()
Returns the first unit of this compound unit (never a compound unit)

Returns:
the first unit.

getNext

public Unit<Q> getNext()
Returns the next unit(s) of this compound unit (can be a compound unit).

Returns:
the next units.

equals

public boolean equals(java.lang.Object that)
Indicates if this compound unit is considered equals to the specified object (both are compound units with same composing units in the same order).

Specified by:
equals in class Unit<Q extends Quantity>
Parameters:
that - the object to compare for equality.
Returns:
true if this and that are considered equals; falseotherwise.

hashCode

public int hashCode()
Description copied from class: Unit
Returns the hash code for this unit.

Specified by:
hashCode in class Unit<Q extends Quantity>
Returns:
this unit hashcode value.

getSystemUnit

public Unit<? super Q> getSystemUnit()
Description copied from class: Unit
Returns the base unit, alternate unit or product of base units and alternate units this unit is derived from. The system unit identifies the "type" of quantity for which this unit is employed. For example:
    boolean isAngularVelocity(Unit<?> u) {
       return u.getSystemUnit().equals(RADIAN.divide(SECOND));
    }
    assert(REVOLUTION.divide(MINUTE).isAngularVelocity());  
 

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).

Specified by:
getSystemUnit in class Unit<Q extends Quantity>
Returns:
the system unit this unit is derived from.

toSystemUnit

public UnitConverter toSystemUnit()
Description copied from class: Unit
Returns the converter from this unit to its system unit.

Specified by:
toSystemUnit in class Unit<Q extends Quantity>
Returns:
this.getConverterTo(this.getSystemUnit())

JSR-275 - Measurements and Units Specification

Copyright © 2007 JSR-275