Class PARTsUnit

java.lang.Object
org.parts3492.partslib.PARTsUnit

public class PARTsUnit extends Object
PARTsUnit - A unit container to store and convert values.
  • Field Details

  • Constructor Details

    • PARTsUnit

      public PARTsUnit(double value, PARTsUnit.PARTsUnitType unitType)
      Create a new PARTsUnit.
      Parameters:
      value - The initial value of the unit.
      unitType - The type that the initial value is currently in.
  • Method Details

    • getValue

      public double getValue()
      Gets the raw value as a double.
      Returns:
      The value as a double.
    • getMagnitude

      public double getMagnitude()
      Gets the absolute value as a double.
      Returns:
      The value as a double.
    • getUnitType

      public PARTsUnit.PARTsUnitType getUnitType()
      Get the current unit type for an instance of PARTsUnit.
      Returns:
      The unit type as a PARTsUnitType.
    • to

      public double to(PARTsUnit.PARTsUnitType unitType)
      Converts current unit into the requested unit.
      Parameters:
      unitType - The target unit.
      Returns:
      Converted unit in double.
    • as

      public PARTsUnit as(PARTsUnit.PARTsUnitType unitType)
      Converts current unit into the requested unit.
      Parameters:
      unitType - The target PARTsUnitType.
      Returns:
      The converted PARTsUnit.