From 2c146c894972e2c6ab701b3c66dcf242d7be656f Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Tue, 24 Dec 2019 16:16:13 -0500 Subject: Added Javadoc to the project. --- doc/org/unitConverter/unit/Unit.html | 632 +++++++++++++++++++++++++++++++++++ 1 file changed, 632 insertions(+) create mode 100644 doc/org/unitConverter/unit/Unit.html (limited to 'doc/org/unitConverter/unit/Unit.html') diff --git a/doc/org/unitConverter/unit/Unit.html b/doc/org/unitConverter/unit/Unit.html new file mode 100644 index 0000000..2a84bfa --- /dev/null +++ b/doc/org/unitConverter/unit/Unit.html @@ -0,0 +1,632 @@ + + + + + +Unit + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.unitConverter.unit
+

Class Unit

+
+
+ +
+
    +
  • +
    +
    Direct Known Subclasses:
    +
    BaseUnit, LinearUnit
    +
    +
    +
    +
    public abstract class Unit
    +extends java.lang.Object
    +
    A unit that is composed of base units.
    +
    +
    Since:
    +
    2019-10-16
    +
    Author:
    +
    Adrien Hopkins
    +
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Unit

        +
        protected Unit(ObjectProduct<BaseUnit> unitBase,
        +               NameSymbol ns)
        +
        Creates the AbstractUnit.
        +
        +
        Parameters:
        +
        unitBase - base of unit
        +
        ns - names and symbol of unit
        +
        Throws:
        +
        java.lang.NullPointerException - if unitBase or ns is null
        +
        Since:
        +
        2019-10-16
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        fromConversionFunctions

        +
        public static final Unit fromConversionFunctions(ObjectProduct<BaseUnit> base,
        +                                                 java.util.function.DoubleUnaryOperator converterFrom,
        +                                                 java.util.function.DoubleUnaryOperator converterTo)
        +
        Returns a unit from its base and the functions it uses to convert to and from its base. + +

        + For example, to get a unit representing the degree Celsius, the following code can be used: + + Unit.fromConversionFunctions(SI.KELVIN, tempK -> tempK - 273.15, tempC -> tempC + 273.15); +

        +
        +
        Parameters:
        +
        base - unit's base
        +
        converterFrom - function that accepts a value expressed in the unit's base and returns that value expressed in this + unit.
        +
        converterTo - function that accepts a value expressed in the unit and returns that value expressed in the unit's + base.
        +
        Returns:
        +
        a unit that uses the provided functions to convert.
        +
        Throws:
        +
        java.lang.NullPointerException - if any argument is null
        +
        Since:
        +
        2019-05-22
        +
        +
      • +
      + + + +
        +
      • +

        fromConversionFunctions

        +
        public static final Unit fromConversionFunctions(ObjectProduct<BaseUnit> base,
        +                                                 java.util.function.DoubleUnaryOperator converterFrom,
        +                                                 java.util.function.DoubleUnaryOperator converterTo,
        +                                                 NameSymbol ns)
        +
        Returns a unit from its base and the functions it uses to convert to and from its base. + +

        + For example, to get a unit representing the degree Celsius, the following code can be used: + + Unit.fromConversionFunctions(SI.KELVIN, tempK -> tempK - 273.15, tempC -> tempC + 273.15); +

        +
        +
        Parameters:
        +
        base - unit's base
        +
        converterFrom - function that accepts a value expressed in the unit's base and returns that value expressed in this + unit.
        +
        converterTo - function that accepts a value expressed in the unit and returns that value expressed in the unit's + base.
        +
        ns - names and symbol of unit
        +
        Returns:
        +
        a unit that uses the provided functions to convert.
        +
        Throws:
        +
        java.lang.NullPointerException - if any argument is null
        +
        Since:
        +
        2019-05-22
        +
        +
      • +
      + + + +
        +
      • +

        canConvertTo

        +
        public final boolean canConvertTo(Unit other)
        +
        Checks if a value expressed in this unit can be converted to a value expressed in other
        +
        +
        Parameters:
        +
        other - unit to test with
        +
        Returns:
        +
        true if the units are compatible
        +
        Throws:
        +
        java.lang.NullPointerException - if other is null
        +
        Since:
        +
        2019-01-13, v0.1.0
        +
        +
      • +
      + + + +
        +
      • +

        convertFromBase

        +
        protected abstract double convertFromBase(double value)
        +
        Converts from a value expressed in this unit's base unit to a value expressed in this unit. +

        + This must be the inverse of convertToBase, so convertFromBase(convertToBase(value)) must be equal + to value for any value, ignoring precision loss by roundoff error. +

        +

        + If this unit is a base unit, this method should return value. +

        +
        +
        Parameters:
        +
        value - value expressed in base unit
        +
        Returns:
        +
        value expressed in this unit
        +
        Since:
        +
        2018-12-22, v0.1.0
        +
        Implementation Requirements:
        +
        This method is used by convertTo(org.unitConverter.unit.Unit, double), and its behaviour affects the behaviour of + convertTo.
        +
        +
      • +
      + + + +
        +
      • +

        convertTo

        +
        public final double convertTo(Unit other,
        +                              double value)
        +
        Converts a value expressed in this unit to a value expressed in other.
        +
        +
        Parameters:
        +
        other - unit to convert to
        +
        value - value to convert
        +
        Returns:
        +
        converted value
        +
        Throws:
        +
        java.lang.IllegalArgumentException - if other is incompatible for conversion with this unit (as tested by + canConvertTo(org.unitConverter.unit.Unit)).
        +
        java.lang.NullPointerException - if other is null
        +
        Since:
        +
        2019-05-22
        +
        Implementation Requirements:
        +
        If unit conversion is possible, this implementation returns + other.convertFromBase(this.convertToBase(value)). Therefore, overriding either of those methods + will change the output of this method.
        +
        +
      • +
      + + + +
        +
      • +

        convertToBase

        +
        protected abstract double convertToBase(double value)
        +
        Converts from a value expressed in this unit to a value expressed in this unit's base unit. +

        + This must be the inverse of convertFromBase, so convertToBase(convertFromBase(value)) must be + equal to value for any value, ignoring precision loss by roundoff error. +

        +

        + If this unit is a base unit, this method should return value. +

        +
        +
        Parameters:
        +
        value - value expressed in this unit
        +
        Returns:
        +
        value expressed in base unit
        +
        Since:
        +
        2018-12-22, v0.1.0
        +
        Implementation Requirements:
        +
        This method is used by convertTo(org.unitConverter.unit.Unit, double), and its behaviour affects the behaviour of + convertTo.
        +
        +
      • +
      + + + +
        +
      • +

        getBase

        +
        public final ObjectProduct<BaseUnit> getBase()
        +
        +
        Returns:
        +
        combination of units that this unit is based on
        +
        Since:
        +
        2018-12-22, v0.1.0
        +
        +
      • +
      + + + +
        +
      • +

        getDimension

        +
        public final ObjectProduct<BaseDimension> getDimension()
        +
        +
        Returns:
        +
        dimension measured by this unit
        +
        Since:
        +
        2018-12-22, v0.1.0
        +
        +
      • +
      + + + +
        +
      • +

        getOtherNames

        +
        public final java.util.Set<java.lang.String> getOtherNames()
        +
        +
        Returns:
        +
        additionalNames
        +
        Since:
        +
        2019-10-21
        +
        +
      • +
      + + + +
        +
      • +

        getPrimaryName

        +
        public final java.util.Optional<java.lang.String> getPrimaryName()
        +
        +
        Returns:
        +
        primaryName
        +
        Since:
        +
        2019-10-21
        +
        +
      • +
      + + + +
        +
      • +

        getSymbol

        +
        public final java.util.Optional<java.lang.String> getSymbol()
        +
        +
        Returns:
        +
        symbol
        +
        Since:
        +
        2019-10-21
        +
        +
      • +
      + + + +
        +
      • +

        toString

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

        withName

        +
        public Unit withName(NameSymbol ns)
        +
        +
        Parameters:
        +
        ns - name(s) and symbol to use
        +
        Returns:
        +
        a copy of this unit with provided name(s) and symbol
        +
        Throws:
        +
        java.lang.NullPointerException - if ns is null
        +
        Since:
        +
        2019-10-21
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + -- cgit v1.2.3