Class AddConverter

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<javax.measure.UnitConverter>, javax.measure.UnitConverter, tech.uom.lib.common.function.ValueSupplier<java.lang.Double>

    public final class AddConverter
    extends AbstractConverter
    implements tech.uom.lib.common.function.ValueSupplier<java.lang.Double>

    This class represents a converter adding a constant offset to numeric values (double based).

    Version:
    1.0, Oct 10, 2016
    See Also:
    Serialized Form
    • Field Detail

      • offset

        private final double offset
        Holds the offset.
    • Constructor Detail

      • AddConverter

        public AddConverter​(double offset)
        Creates an additive converter having the specified offset.
        Parameters:
        offset - the offset value.
    • Method Detail

      • getOffset

        public double getOffset()
        Returns the offset value for this add converter.
        Returns:
        the offset value.
      • isIdentity

        public boolean isIdentity()
        Specified by:
        isIdentity in interface javax.measure.UnitConverter
      • inverseWhenNotIdentity

        public AddConverter inverseWhenNotIdentity()
        Description copied from class: AbstractConverter
        Non-API

        Returns an AbstractConverter that represents the inverse transformation of this converter, for cases where the transformation is not the identity transformation.

        Specified by:
        inverseWhenNotIdentity in class AbstractConverter
        Returns:
      • convertWhenNotIdentity

        public java.math.BigDecimal convertWhenNotIdentity​(java.math.BigDecimal value,
                                                           java.math.MathContext ctx)
                                                    throws java.lang.ArithmeticException
        Description copied from class: AbstractConverter
        Non-API
        Specified by:
        convertWhenNotIdentity in class AbstractConverter
        Returns:
        transformed value
        Throws:
        java.lang.ArithmeticException
      • transformationLiteral

        public java.lang.String transformationLiteral()
        Description copied from class: AbstractConverter
        Non-API

        Returns a String describing the transformation that is represented by this converter. Contributes to converter's toString method. If null or empty toString output becomes simplified.

        Specified by:
        transformationLiteral in class AbstractConverter
        Returns:
      • isLinear

        public boolean isLinear()
        Specified by:
        isLinear in interface javax.measure.UnitConverter
      • getValue

        public java.lang.Double getValue()
        Specified by:
        getValue in interface tech.uom.lib.common.function.ValueSupplier<java.lang.Double>
      • compareTo

        public int compareTo​(javax.measure.UnitConverter o)
        Specified by:
        compareTo in interface java.lang.Comparable<javax.measure.UnitConverter>