Interface ScalarFactory<Q extends javax.measure.Quantity<Q>>

Type Parameters:
Q - the type of quantities created by this factory.

interface ScalarFactory<Q extends javax.measure.Quantity<Q>>
Creates quantities for the given value and unit of measurement.
Since:
0.8
Version:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    create(double value, javax.measure.Unit<Q> unit)
    Creates a new quantity for the given value and unit of measurement.
    default Q
    createDerived(double value, javax.measure.Unit<Q> unit, javax.measure.Unit<Q> systemUnit, javax.measure.UnitConverter toSystem)
    Creates a new quantity for the given value and unit of measurement which is not convertible to system unit by a scale factor.
  • Method Details

    • create

      Q create(double value, javax.measure.Unit<Q> unit)
      Creates a new quantity for the given value and unit of measurement. This method is invoked only when the given unit is convertible to system unit with a scale factor (no offset). This is the case of most units of measurement.
      Parameters:
      value - the value of the quantity to create.
      unit - the unit of measurement associated to the given value.
      Returns:
      a quantity with the given value and unit of measurement.
    • createDerived

      default Q createDerived(double value, javax.measure.Unit<Q> unit, javax.measure.Unit<Q> systemUnit, javax.measure.UnitConverter toSystem)
      Creates a new quantity for the given value and unit of measurement which is not convertible to system unit by a scale factor. Example of such quantities is a temperature measurement in Celsius degrees, since conversion to Kelvin implies an offset.
      Parameters:
      value - the value of the quantity to create.
      unit - the unit of measurement associated to the given value.
      systemUnit - Unit.getSystemUnit(), opportunistically provided because already known by the caller.
      toSystem - unit.getConverterTo(systemUnit), provided because already known by the caller.
      Returns:
      a quantity with the given value and unit of measurement, or null if no predefined implementation is available.