Class MultiplyConverter

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

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

    This class represents a converter multiplying numeric values by a constant scaling factor (double based).

    Since:
    1.0
    Version:
    1.1, Apr 18, 2018
    See Also:
    Serialized Form
    • Field Detail

      • factor

        private final double factor
        Holds the scale factor.
    • Constructor Detail

      • MultiplyConverter

        public MultiplyConverter​(double factor)
        Creates a multiply converter with the specified scale factor.
        Parameters:
        factor - the scaling factor.
    • Method Detail

      • of

        public static MultiplyConverter of​(double factor)
        Creates a multiply converter with the specified scale factor.
        Parameters:
        factor - the scaling factor.
      • getFactor

        public double getFactor()
        Returns the scale factor of this converter.
        Specified by:
        getFactor in interface tech.uom.lib.common.function.DoubleFactorSupplier
        Returns:
        the scale factor.
      • isIdentity

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

        public MultiplyConverter 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 final 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>