Class ConcatenatedConverter

java.lang.Object
org.apache.sis.measure.AbstractConverter
org.apache.sis.measure.ConcatenatedConverter
All Implemented Interfaces:
Serializable, javax.measure.UnitConverter, LenientComparable

final class ConcatenatedConverter extends AbstractConverter implements LenientComparable
The concatenation of two unit converters where at least one of them is not linear.
Since:
0.8
Version:
0.8
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final javax.measure.UnitConverter
    The first unit converter to apply.
    private final javax.measure.UnitConverter
    The second unit converter to apply, after c1.
    The inverse of this unit converter.
    private static final long
    For cross-version compatibility.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConcatenatedConverter(javax.measure.UnitConverter c1, javax.measure.UnitConverter c2)
    Creates a new concatenation of the given unit converters.
  • Method Summary

    Modifier and Type
    Method
    Description
    javax.measure.UnitConverter
    concatenate(javax.measure.UnitConverter converter)
    Concatenates this converter with another converter.
    double
    convert(double value)
    Applies the linear conversion on the given IEEE 754 floating-point value.
    convert(Number value)
    Applies the linear conversion on the given value.
    double
    derivative(double value)
    Returns the derivative of the conversion function at the given value, or NaN if unknown.
    boolean
    equals(Object other)
    Compares this converter with the given object for equality.
    boolean
    Compares this converter with the given object for equality, optionally ignoring rounding errors.
    List<javax.measure.UnitConverter>
    Returns the steps of fundamental converters making up this converter.
    int
    Returns a hash code value for this unit converter.
    javax.measure.UnitConverter
    Returns the inverse of this unit converter.
    boolean
    Returns true if the two unit converters are identity converters.
    boolean
    Returns true if the two unit converters are linear converters.

    Methods inherited from class org.apache.sis.measure.AbstractConverter

    coefficients, derivative, doubleValue, epsilonEquals, scale

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • c1

      private final javax.measure.UnitConverter c1
      The first unit converter to apply.
    • c2

      private final javax.measure.UnitConverter c2
      The second unit converter to apply, after c1.
    • inverse

      private transient ConcatenatedConverter inverse
      The inverse of this unit converter. Computed when first needed and stored in order to avoid rounding error if the user asks for the inverse of the inverse.
  • Constructor Details

    • ConcatenatedConverter

      ConcatenatedConverter(javax.measure.UnitConverter c1, javax.measure.UnitConverter c2)
      Creates a new concatenation of the given unit converters. Values will be converted according c1 first, then c2.
  • Method Details

    • isIdentity

      public boolean isIdentity()
      Returns true if the two unit converters are identity converters. Should always be false, otherwise we would not have created a ConcatenatedConverter.
      Specified by:
      isIdentity in interface javax.measure.UnitConverter
      Overrides:
      isIdentity in class AbstractConverter
    • isLinear

      public boolean isLinear()
      Returns true if the two unit converters are linear converters. Should always be false, otherwise we would not have created a ConcatenatedConverter.
      Specified by:
      isLinear in interface javax.measure.UnitConverter
      Overrides:
      isLinear in class AbstractConverter
    • inverse

      public javax.measure.UnitConverter inverse()
      Returns the inverse of this unit converter.
      Specified by:
      inverse in interface javax.measure.UnitConverter
    • convert

      public double convert(double value)
      Applies the linear conversion on the given IEEE 754 floating-point value.
      Specified by:
      convert in interface javax.measure.UnitConverter
    • convert

      public Number convert(Number value)
      Applies the linear conversion on the given value.
      Specified by:
      convert in interface javax.measure.UnitConverter
      Overrides:
      convert in class AbstractConverter
    • derivative

      public double derivative(double value)
      Returns the derivative of the conversion function at the given value, or NaN if unknown.
      Specified by:
      derivative in class AbstractConverter
      Parameters:
      value - the point at which to compute the derivative. Ignored (can be Double.NaN) if the conversion is linear.
    • concatenate

      public javax.measure.UnitConverter concatenate(javax.measure.UnitConverter converter)
      Concatenates this converter with another converter. The resulting converter is equivalent to first converting by the specified converter (right converter), and then converting by this converter (left converter).
      Specified by:
      concatenate in interface javax.measure.UnitConverter
      Overrides:
      concatenate in class AbstractConverter
    • getConversionSteps

      public List<javax.measure.UnitConverter> getConversionSteps()
      Returns the steps of fundamental converters making up this converter. For example, c1.getConversionSteps() returns c1 while c1.concatenate(c2).getConversionSteps() returns c1, c2.
      Specified by:
      getConversionSteps in interface javax.measure.UnitConverter
      Overrides:
      getConversionSteps in class AbstractConverter
    • hashCode

      public int hashCode()
      Returns a hash code value for this unit converter.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Compares this converter with the given object for equality.
      Specified by:
      equals in interface LenientComparable
      Overrides:
      equals in class Object
      Parameters:
      other - the object to compare to this.
      Returns:
      true if both objects are strictly equal.
      See Also:
    • equals

      public boolean equals(Object other, ComparisonMode mode)
      Compares this converter with the given object for equality, optionally ignoring rounding errors.
      Specified by:
      equals in interface LenientComparable
      Parameters:
      other - the object to compare to this.
      mode - the strictness level of the comparison.
      Returns:
      true if both objects are equal according the given comparison mode.
      See Also: