Package com.irurueta.units
Class Weight
- All Implemented Interfaces:
Serializable
Contains a weight value and unit.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionWeight()Constructor.Weight(Number value, WeightUnit unit) Constructor with value and unit. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(double value, WeightUnit unit) Adds provided weight value and unit and updates current weight instance.static doubleadd(double value1, WeightUnit unit1, double value2, WeightUnit unit2, WeightUnit resultUnit) Adds two weight values and units and returns the result.voidAdds provided weight and updates current weight.voidAdds provided weight and stores the result into provided weight.static voidAdds two weights and stores the result into provided instance.voidadd(Number value, WeightUnit unit) Adds provided weight value and unit and updates current weight instance.static Numberadd(Number value1, WeightUnit unit1, Number value2, WeightUnit unit2, WeightUnit resultUnit) Adds two weight values and units and returns the result.addAndReturnNew(double value, WeightUnit unit, WeightUnit resultUnit) Adds provided weight value and unit and returns a new weight instance using provided unit.static WeightaddAndReturnNew(Weight arg1, Weight arg2, WeightUnit unit) Adds two weights.addAndReturnNew(Weight w, WeightUnit unit) Adds provided weight to current instance and returns a new weight.addAndReturnNew(Number value, WeightUnit unit, WeightUnit resultUnit) Adds provided weight value and unit and returns a new weight instance using provided unit.booleanequals(Measurement<WeightUnit> other, double tolerance) Determines if two weights are equal up to a certain tolerance.voidsubtract(double value, WeightUnit unit) Subtracts provided weight value and unit and updates current weight instance.static doublesubtract(double value1, WeightUnit unit1, double value2, WeightUnit unit2, WeightUnit resultUnit) Subtracts two weight values and units and returns the result.voidSubtracts provided weight and updates current weight.voidSubtracts provided weight and stores the result into provided weight.static voidSubtracts two weights and stores the result into provided instance.voidsubtract(Number value, WeightUnit unit) Subtracts provided weight value and unit and updates current weight instance.static Numbersubtract(Number value1, WeightUnit unit1, Number value2, WeightUnit unit2, WeightUnit resultUnit) Subtracts two weight values and units and returns the result.subtractAndReturnNew(double value, WeightUnit unit, WeightUnit resultUnit) Subtracts provided weight value and unit and returns a new weight instance using provided unit.static WeightsubtractAndReturnNew(Weight arg1, Weight arg2, WeightUnit unit) Subtracts two weights.subtractAndReturnNew(Weight w, WeightUnit unit) Subtracts provided weight from current instance and returns a new weight.subtractAndReturnNew(Number value, WeightUnit unit, WeightUnit resultUnit) Subtracts provided weight value and unit and returns a new weight instance using provided unit.
-
Constructor Details
-
Weight
Constructor with value and unit.- Parameters:
value- weight value.unit- unit of weight.- Throws:
IllegalArgumentException- if either value or unit is null.
-
Weight
Weight()Constructor.
-
-
Method Details
-
equals
Determines if two weights are equal up to a certain tolerance. If needed, this method attempts unit conversion to compare both objects.- Overrides:
equalsin classMeasurement<WeightUnit>- Parameters:
other- another measurement to compare.tolerance- amount of tolerance to determine whether two measurements are equal or not.- Returns:
- true if provided weight is assumed to be equal to this instance, false otherwise.
-
add
public static double add(double value1, WeightUnit unit1, double value2, WeightUnit unit2, WeightUnit resultUnit) Adds two weight 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, WeightUnit unit1, Number value2, WeightUnit unit2, WeightUnit resultUnit) Adds two weight 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
Adds two weights and stores the result into provided instance.- Parameters:
arg1- 1st argument.arg2- 2nd argument.result- instance where result will be stored.
-
addAndReturnNew
Adds two weights.- Parameters:
arg1- 1st argument.arg2- 2nd argument.unit- unit of returned weight.- Returns:
- a new instance containing result.
-
addAndReturnNew
Adds provided weight value and unit and returns a new weight instance using provided unit.- Parameters:
value- value to be added.unit- unit of value to be added.resultUnit- unit of returned weight.- Returns:
- a new weight containing result.
-
addAndReturnNew
Adds provided weight value and unit and returns a new weight instance using provided unit.- Parameters:
value- value to be added.unit- unit of value to be added.resultUnit- unit of returned weight.- Returns:
- a new weight containing result.
-
addAndReturnNew
Adds provided weight to current instance and returns a new weight.- Parameters:
w- weight to be added.unit- unit of returned weight.- Returns:
- a new weight containing result.
-
add
Adds provided weight value and unit and updates current weight instance.- Parameters:
value- weight value to be added.unit- unit of weight value.
-
add
Adds provided weight value and unit and updates current weight instance.- Parameters:
value- weight value to be added.unit- unit of weight value.
-
add
Adds provided weight and updates current weight.- Parameters:
weight- weight to be added.
-
add
Adds provided weight and stores the result into provided weight.- Parameters:
w- weight to be added.result- instance where result will be stored.
-
subtract
public static double subtract(double value1, WeightUnit unit1, double value2, WeightUnit unit2, WeightUnit resultUnit) Subtracts two weight 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, WeightUnit unit1, Number value2, WeightUnit unit2, WeightUnit resultUnit) Subtracts two weight 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
Subtracts two weights and stores the result into provided instance.- Parameters:
arg1- 1st argument.arg2- 2nd argument.result- instance where result will be stored.
-
subtractAndReturnNew
Subtracts two weights.- Parameters:
arg1- 1st argument.arg2- 2nd argument.unit- unit of returned weight.- Returns:
- a new instance containing result.
-
subtractAndReturnNew
Subtracts provided weight value and unit and returns a new weight instance using provided unit.- Parameters:
value- value to be subtracted.unit- unit of value to be subtracted.resultUnit- unit of returned weight.- Returns:
- a new weight containing result.
-
subtractAndReturnNew
Subtracts provided weight value and unit and returns a new weight instance using provided unit.- Parameters:
value- value to be subtracted.unit- unit of value to be subtracted.resultUnit- unit of returned weight.- Returns:
- a new weight containing result.
-
subtractAndReturnNew
Subtracts provided weight from current instance and returns a new weight.- Parameters:
w- weight to be subtracted.unit- unit of returned weight.- Returns:
- a new weight containing result.
-
subtract
Subtracts provided weight value and unit and updates current weight instance.- Parameters:
value- weight value to be subtracted.unit- unit of weight value.
-
subtract
Subtracts provided weight value and unit and updates current weight instance.- Parameters:
value- weight value to be subtracted.unit- unit of weight value.
-
subtract
Subtracts provided weight and updates current weight.- Parameters:
weight- weight to be subtracted.
-
subtract
Subtracts provided weight and stores the result into provided weight.- Parameters:
w- weight to be subtracted.result- instance where result will be stored.
-