|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.measure.unit.Unit<Q>
javax.measure.unit.DerivedUnit<Q>
javax.measure.unit.AnnotatedUnit<Q>
public class AnnotatedUnit<Q extends Quantity>
This class represents an annotated unit. It allows for unit specialization
and annotation without changing the unit semantic. For example:
public class Size extends Measurable<Length> {
private double meters;
...
public static class Unit extends AnnotatedUnit<Length> {
private Unit(javax.measure.unit.Unit<Length> realUnit, String annotation) {
super(realUnit, annotation);
}
public static Size.Unit METER = new Size.Unit(SI.METER, "SIZE"); // Equivalent to SI.METER
public static Size.Unit INCH = new Size.Unit(NonSI.INCH, "SIZE"); // Equivalent to NonSI.INCH
}
}
Annotation are often written between curly braces behind units but they do not change, for example "%{vol}", "kg{total}", or "{RBC}" (for "red blood cells") are equivalent to "%", "kg", and "1" respectively.
| Field Summary |
|---|
| Fields inherited from class javax.measure.unit.Unit |
|---|
ONE |
| Constructor Summary | |
|---|---|
AnnotatedUnit(Unit<Q> realUnit,
java.lang.String annotation)
Creates an annotated unit for the specified unit. |
|
| Method Summary | |
|---|---|
boolean |
equals(java.lang.Object that)
Indicates if the specified unit can be considered equals to the one specified. |
java.lang.String |
getAnnotation()
Returns the annotation of this unit. |
UnitConverter |
getConverterTo(Unit<Q> unit)
Returns a converter of numeric values from this unit to another unit. |
Unit<Q> |
getRealUnit()
Returns the equivalent non-annotated unit. |
int |
hashCode()
Returns the hash code for this unit. |
Unit<Q> |
toSI()
Returns the standard unit from which this unit is derived. |
| Methods inherited from class javax.measure.unit.Unit |
|---|
alternate, asType, compound, divide, divide, divide, getDimension, inverse, isCompatible, isSI, plus, pow, root, times, times, times, toString, transform, valueOf |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AnnotatedUnit(Unit<Q> realUnit,
java.lang.String annotation)
realUnit - the real unit.annotation - the annotation.| Method Detail |
|---|
public java.lang.String getAnnotation()
public final Unit<Q> getRealUnit()
public final Unit<Q> toSI()
Unitquantity
for which this unit is employed. For example:
boolean isAngularVelocity(Unit<?> u) {
return u.toSI().equals(RADIAN.divide(SECOND));
}
assert(REVOLUTION.divide(MINUTE).isAngularVelocity());
Note: Having the same SI unit is not sufficient to ensure that a converter exists between the two units (e.g. °C/m and K/m).
toSI in class Unit<Q extends Quantity>public final UnitConverter getConverterTo(Unit<Q> unit)
Unitstandard unit.
getConverterTo in class Unit<Q extends Quantity>unit - the unit to which to convert the numeric values.
that unit.public boolean equals(java.lang.Object that)
Unit
equals in class Unit<Q extends Quantity>that - the object to compare to.
true if this unit is considered equal to that unit;
false otherwise.public int hashCode()
Unit
hashCode in class Unit<Q extends Quantity>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||