Interface Unit<U extends Unit<U>>

All Superinterfaces:
Serializable
All Known Implementing Classes:
Data, Duration, Money, Occurrence

public interface Unit<U extends Unit<U>> extends Serializable
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 Classes
    Modifier and Type
    Interface
    Description
    static class 
    Exception class to support where any mathematical operation between two or more Unit types is not supported.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final MathContext
     
  • Method Summary

    Modifier and Type
    Method
    Description
    convert(UnitValue<U> otherValue)
    Returns an instance of the UnitValue with this Unit converted according to a specific ratio
    long
    Deprecated.
    Returns an instance of the UnitValue with this Unit and provided quantity
  • Field Details

  • Method Details

    • getRatio

      @Deprecated long getRatio(U u) throws Unit.UnitMisMatchException
      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

      UnitValue<U> valueOf(BigDecimal b)
      Returns an instance of the UnitValue with this Unit and provided quantity
      Parameters:
      b - BigDecimal
      Returns:
      UnitValue
    • convert

      UnitValue<U> convert(UnitValue<U> otherValue)
      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