Class Volume

All Implemented Interfaces:
Serializable

public class Volume extends Measurement<VolumeUnit>
Contains a volume value and unit.
See Also:
  • Constructor Details

    • Volume

      public Volume(Number value, VolumeUnit unit)
      Constructor with value and unit.
      Parameters:
      value - volume value.
      unit - unit of volume.
      Throws:
      IllegalArgumentException - if either value or unit is null.
    • Volume

      Volume()
      Constructor.
  • Method Details

    • equals

      public boolean equals(Measurement<VolumeUnit> other, double tolerance)
      Determine if two volumes are equal up to a certain tolerance. If needed, this method attempts unit conversion to compare both objects.
      Overrides:
      equals in class Measurement<VolumeUnit>
      Parameters:
      other - another measurement to compare.
      tolerance - amount of tolerance to determine whether two measurements are equal or not.
      Returns:
      true if provided volume is assumed to be equal to this instance, false otherwise.
    • add

      public static double add(double value1, VolumeUnit unit1, double value2, VolumeUnit unit2, VolumeUnit resultUnit)
      Adds two volume values and units and returns the result.
      Parameters:
      value1 - 1st argument value.
      unit1 - 1st argument unit.
      value2 - 2nd argument value.
      unit2 - 2nd argument unit.
      resultUnit - unit of result to be returned.
      Returns:
      result of addition.
    • add

      public static Number add(Number value1, VolumeUnit unit1, Number value2, VolumeUnit unit2, VolumeUnit resultUnit)
      Adds two volume values and units and returns the result.
      Parameters:
      value1 - 1st argument value.
      unit1 - 1st argument unit.
      value2 - 2nd argument value.
      unit2 - 2nd argument unit.
      resultUnit - unit of result to be returned.
      Returns:
      result of addition.
    • add

      public static void add(Volume arg1, Volume arg2, Volume result)
      Adds two volumes and stores the result into provided instance.
      Parameters:
      arg1 - 1st argument.
      arg2 - 2nd argument.
      result - instance where result will be stored.
    • addAndReturnNew

      public static Volume addAndReturnNew(Volume arg1, Volume arg2, VolumeUnit unit)
      Adds two volumes.
      Parameters:
      arg1 - 1st argument.
      arg2 - 2nd argument.
      unit - unit of returned volume.
      Returns:
      a new instance containing result.
    • addAndReturnNew

      public Volume addAndReturnNew(double value, VolumeUnit unit, VolumeUnit resultUnit)
      Adds provided volume value and unit and returns a new volume instance using provided unit.
      Parameters:
      value - value to be added.
      unit - unit of value to be added.
      resultUnit - unit of returned volume.
      Returns:
      a new volume containing result.
    • addAndReturnNew

      public Volume addAndReturnNew(Number value, VolumeUnit unit, VolumeUnit resultUnit)
      Adds provided volume value and unit and returns a new volume instance using provided unit.
      Parameters:
      value - value to be added.
      unit - unit of value to be added.
      resultUnit - unit of returned volume.
      Returns:
      a new volume containing result.
    • addAndReturnNew

      public Volume addAndReturnNew(Volume v, VolumeUnit unit)
      Adds provided volume to current instance and returns a new volume.
      Parameters:
      v - volume to be added.
      unit - unit of returned volume.
      Returns:
      a new volume containing result.
    • add

      public void add(double value, VolumeUnit unit)
      Adds provided volume value and unit and updates current volume instance.
      Parameters:
      value - volume value to be added.
      unit - unit of volume value.
    • add

      public void add(Number value, VolumeUnit unit)
      Adds provided volume value and unit and updates current volume instance.
      Parameters:
      value - volume value to be added.
      unit - unit of volume value.
    • add

      public void add(Volume volume)
      Adds provided volume and updates current volume.
      Parameters:
      volume - volume to be added.
    • add

      public void add(Volume v, Volume result)
      Adds provided volume and stores the result into provided volume.
      Parameters:
      v - volume to be added.
      result - instance where result will be stored.
    • subtract

      public static double subtract(double value1, VolumeUnit unit1, double value2, VolumeUnit unit2, VolumeUnit resultUnit)
      Subtracts two volume values and units and returns the result.
      Parameters:
      value1 - 1st argument value.
      unit1 - 1st argument unit.
      value2 - 2nd argument value.
      unit2 - 2nd argument unit.
      resultUnit - unit of result to be returned.
      Returns:
      result of subtraction.
    • subtract

      public static Number subtract(Number value1, VolumeUnit unit1, Number value2, VolumeUnit unit2, VolumeUnit resultUnit)
      Subtracts two volume values and units and returns the result.
      Parameters:
      value1 - 1st argument value.
      unit1 - 1st argument unit.
      value2 - 2nd argument value.
      unit2 - 2nd argument unit.
      resultUnit - unit of result to be returned.
      Returns:
      result of subtraction.
    • subtract

      public static void subtract(Volume arg1, Volume arg2, Volume result)
      Subtracts two volumes and stores the result into provided instance.
      Parameters:
      arg1 - 1st argument.
      arg2 - 2nd argument.
      result - instance where result will be stored.
    • subtractAndReturnNew

      public static Volume subtractAndReturnNew(Volume arg1, Volume arg2, VolumeUnit unit)
      Subtracts two volumes.
      Parameters:
      arg1 - 1st argument.
      arg2 - 2nd argument.
      unit - unit of returned volume.
      Returns:
      a new instance containing result.
    • subtractAndReturnNew

      public Volume subtractAndReturnNew(double value, VolumeUnit unit, VolumeUnit resultUnit)
      Subtracts provided volume value and unit and returns a new volume instance using provided unit.
      Parameters:
      value - value to be subtracted.
      unit - unit of value to be subtracted.
      resultUnit - unit of returned volume.
      Returns:
      a new volume containing result.
    • subtractAndReturnNew

      public Volume subtractAndReturnNew(Number value, VolumeUnit unit, VolumeUnit resultUnit)
      Subtracts provided volume value and unit and returns a new volume instance using provided unit.
      Parameters:
      value - value to be subtracted.
      unit - unit of value to be subtracted.
      resultUnit - unit of returned volume.
      Returns:
      a new volume containing result.
    • subtractAndReturnNew

      public Volume subtractAndReturnNew(Volume v, VolumeUnit unit)
      Subtracts provided volume from current instance and returns a new volume.
      Parameters:
      v - volume to be subtracted.
      unit - unit of returned volume.
      Returns:
      a new volume containing result.
    • subtract

      public void subtract(double value, VolumeUnit unit)
      Subtracts provided volume value and unit and updates current volume instance.
      Parameters:
      value - volume value to be subtracted.
      unit - unit of volume value.
    • subtract

      public void subtract(Number value, VolumeUnit unit)
      Subtracts provided volume value and unit and updates current volume instance.
      Parameters:
      value - volume value to be subtracted.
      unit - unit of volume value.
    • subtract

      public void subtract(Volume volume)
      Subtracts provided volume and updates current volume.
      Parameters:
      volume - volume to be subtracted.
    • subtract

      public void subtract(Volume v, Volume result)
      Subtracts provided volume and stores the result into provided volume.
      Parameters:
      v - volume to be subtracted.
      result - instance where result will be stored.