Class QuantityType<T extends javax.measure.Quantity<T>>

    • Field Detail

      • ZERO

        public static final QuantityType<javax.measure.quantity.Dimensionless> ZERO
      • ONE

        public static final QuantityType<javax.measure.quantity.Dimensionless> ONE
    • Constructor Detail

      • QuantityType

        public QuantityType()
        Creates a dimensionless QuantityType with scalar 0 and unit AbstractUnit.ONE. A default constructor is needed by ItemUpdater.receiveUpdate(org.eclipse.smarthome.core.items.events.ItemStateEvent))
      • QuantityType

        public QuantityType​(String value)
        Creates a new QuantityType with the given value. The value may contain a unit. The specific Quantity is obtained by Quantities.getQuantity(CharSequence).
        Parameters:
        value - the non null value representing a quantity with an optional unit.
      • QuantityType

        public QuantityType​(Number value,
                            javax.measure.Unit<T> unit)
        Creates a new QuantityType with the given value and Unit.
        Parameters:
        value - the non null measurement value.
        unit - the non null measurement unit.
        conversionUnits - the optional unit map which is used to determine the MeasurementSystem specific unit for conversion.
    • Method Detail

      • valueOf

        public static <T extends javax.measure.Quantity<T>> QuantityType<T> valueOf​(double value,
                                                                                    javax.measure.Unit<T> unit)
        Static access to QuantityType#QuantityType(double, Unit).
        Parameters:
        value - the non null measurement value.
        unit - the non null measurement unit.
        Returns:
        a new QuantityType
      • valueOf

        public static QuantityType<? extends javax.measure.Quantity<?>> valueOf​(String value)
      • equals

        public boolean equals​(@Nullable Object obj)
        Overrides:
        equals in class Object
      • getUnit

        public javax.measure.Unit<T> getUnit()
      • getDimension

        public javax.measure.Dimension getDimension()
      • toUnit

        public @Nullable QuantityType<T> toUnit​(javax.measure.Unit<?> targetUnit)
        Convert this QuantityType to a new QuantityType using the given target unit.
        Parameters:
        targetUnit - the unit to which this QuantityType will be converted to.
        Returns:
        the new QuantityType in the given Unit or null in case of a
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • format

        public String format​(String pattern)
        Description copied from interface: Type
        Formats the value of this type according to a pattern (see Formatter).
        Specified by:
        format in interface Type
        Parameters:
        pattern - the pattern to use
        Returns:
        the formatted string
      • intValue

        public int intValue()
        Specified by:
        intValue in class Number
      • longValue

        public long longValue()
        Specified by:
        longValue in class Number
      • floatValue

        public float floatValue()
        Specified by:
        floatValue in class Number
      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in class Number
      • toFullString

        public String toFullString()
        Description copied from interface: Type
        Get a string representation that contains the whole internal representation of the type.

        The returned string could be consumed by the static 'valueOf(String)' method of the respective type to build a new type that is equal to this type.

        Specified by:
        toFullString in interface Type
        Returns:
        a full string representation of the type to be consumed by 'valueOf(String)'
      • as

        public <U extends State> @Nullable U as​(@Nullable Class<U> target)
        Description copied from interface: State
        Convert this State's value into another type
        Specified by:
        as in interface State
        Parameters:
        target - the desired State type
        Returns:
        the State's value in the given type's representation, or null if the conversion was not possible
      • negate

        public QuantityType<T> negate()
        Negates the value of this QuantityType leaving its unit untouched.
        Returns:
        the negated value of this QuantityType.
      • divide

        public QuantityType<?> divide​(BigDecimal value)
        Divide this QuantityType by the given value.
        Parameters:
        value - the value this QuantityType should be divided by.
        Returns:
        the quotient from this QuantityType and the given value.
      • offset

        public QuantityType<T> offset​(QuantityType<T> offset,
                                      javax.measure.Unit<T> unit)
        Apply a given offset to this QuantityType
        Parameters:
        offset - the offset to apply
        Returns:
        changed QuantityType by offset