Interface Unit<U extends Unit<U>>
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
Data
,Duration
,Money
,Occurrence
Represents a generic unit of measurement. Any measurable unit for Rating can be
represented by the Unit interface. Each Unit has a symbol like "sec" - if measuring
duration or "KB" - if measuring data volume and an internal symbol table. The
symbol table assists in local conversion between supported units like a factor of 1000
if it is a millisecond to second and 1024 between Bytes and KiloBytes.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Exception class to support where any mathematical operation between two or more Unit types is not supported. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns an instance of the UnitValue with this Unit converted according to a specific ratiolong
Deprecated.Returns an instance of the UnitValue with this Unit and provided quantity
-
Field Details
-
MATH_CONTEXT
-
-
Method Details
-
getRatio
Deprecated.NOTE: for backward compatibility, actually obsolete Deprecated, use convert instead The method returns the ratio of numeric conversion between the this and the passed unit. The method throws Unit.UnitMisMatchException if ratio between the two units is not supported.- Parameters:
u
- Unit- Returns:
- long the ratio between the two Units.
- Throws:
Unit.UnitMisMatchException
- If ration cannot be obtained between two Units.
-
valueOf
Returns an instance of the UnitValue with this Unit and provided quantity- Parameters:
b
- BigDecimal- Returns:
- UnitValue
-
convert
Returns an instance of the UnitValue with this Unit converted according to a specific ratio- Parameters:
otherValue
- UnitValue unit value to convert to- Returns:
- UnitValue unit value resulting from conversion of otherValue to the unit
-