Class AbstractConverter

    • Field Detail

      • conversionSteps

        protected java.util.List<? extends javax.measure.UnitConverter> conversionSteps
        memoization for getConversionSteps
    • Constructor Detail

      • AbstractConverter

        protected AbstractConverter()
        DefaultQuantityFactory constructor.
    • Method Detail

      • of

        public static javax.measure.UnitConverter of​(Prefix prefix)
        Creates a converter with the specified Prefix.
        Parameters:
        prefix - the prefix for the factor.
      • equals

        public abstract boolean equals​(java.lang.Object cvtr)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public abstract int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • transformationLiteral

        protected abstract java.lang.String transformationLiteral()
        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.

        Returns:
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • inverseWhenNotIdentity

        protected abstract AbstractConverter inverseWhenNotIdentity()
        Non-API

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

        Returns:
      • inverse

        public final AbstractConverter inverse()
        Specified by:
        inverse in interface javax.measure.UnitConverter
      • isSimpleCompositionWith

        protected abstract boolean isSimpleCompositionWith​(AbstractConverter that)
        Parameters:
        that -
        Returns:
        whether or not a 'simple' composition of transformations is possible
      • concatenate

        public final javax.measure.UnitConverter concatenate​(javax.measure.UnitConverter converter)
        Specified by:
        concatenate in interface javax.measure.UnitConverter
      • getConversionSteps

        public final java.util.List<? extends javax.measure.UnitConverter> getConversionSteps()
        Specified by:
        getConversionSteps in interface javax.measure.UnitConverter
      • convertWhenNotIdentity

        protected abstract double convertWhenNotIdentity​(double value)
        Non-API
        Parameters:
        value -
        Returns:
        transformed value
      • convertWhenNotIdentity

        protected java.lang.Number convertWhenNotIdentity​(java.math.BigInteger value,
                                                          java.math.MathContext ctx)
        Non-API
        Parameters:
        value -
        ctx -
        Returns:
        transformed value (most likely a BigInteger or BigDecimal)
      • convertWhenNotIdentity

        protected abstract java.math.BigDecimal convertWhenNotIdentity​(java.math.BigDecimal value,
                                                                       java.math.MathContext ctx)
        Non-API
        Parameters:
        value -
        ctx -
        Returns:
        transformed value
      • convert

        public final double convert​(double value)
        Specified by:
        convert in interface javax.measure.UnitConverter
      • convert

        public final java.lang.Number convert​(java.lang.Number value)
        Specified by:
        convert in interface javax.measure.UnitConverter
        Throws:
        java.lang.IllegalArgumentException - if the value is null.