Class Quantity
java.lang.Object
org.salespointframework.quantity.Quantity
A value object to represent a quantity.
- Author:
- Oliver Gierke, Martin Morgenstern
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionAdds the givenQuantityto the current one.protected booleanboolean@NonNull BigDecimalThe amount of the Quantity.@NonNull MetricThe metric of the Quantity.inthashCode()booleanisCompatibleWith(Metric metric) booleanReturns whether the currentQuantityis equal to the given one negelecting potential differences in precision of the underlying amount.booleanisGreaterThan(Quantity other) Returns whether the givenQuantityis greater than the current one.booleanisGreaterThanOrEqualTo(Quantity other) Returns whether the givenQuantityis greater than or equal to the current one.booleanisLessThan(Quantity other) Returns whether the givenQuantityis less than the current one.booleanReturns whether the currentQuantityis negative.booleanReturns whether the currentQuantityis positive.booleanReturns whether the currentQuantityis zero or negative.booleanReturns whether the currentQuantityis zero or positive.negate()Returns the negatedQuantity.static Quantityof(double amount) Creates a newQuantityof the given amount.static Quantitystatic Quantityof(long amount) Creates a newQuantityof the given amount.static QuantitySubtracts the given Quantity from the current one.times(int multiplier) Creates a newQuantityof the current one multiplied with the given int.times(long multiplier) Creates a newQuantityof the current one multiplied with the given long.toString()toUnit()Returns the currentQuantityas units, flattening all non unit metrics into a single unit.toZero()
-
Field Details
-
NONE
-
-
Method Details
-
of
Creates a newQuantityof the given amount. Defaults the metric toMetric.UNIT.- Parameters:
amount- must not be null.- Returns:
-
of
Creates a newQuantityof the given amount. Defaults the metric toMetric.UNIT.- Parameters:
amount- must not be null.- Returns:
-
of
-
of
-
isCompatibleWith
-
add
-
subtract
-
isLessThan
-
times
-
times
-
isEqualTo
-
isGreaterThan
-
isGreaterThanOrEqualTo
-
isPositive
-
isZeroOrPositive
public boolean isZeroOrPositive()Returns whether the currentQuantityis zero or positive.- Returns:
- Since:
- 7.5
-
isNegative
-
isZeroOrNegative
public boolean isZeroOrNegative()Returns whether the currentQuantityis zero or negative.- Returns:
-
toZero
-
toUnit
-
negate
-
toString
-
equals
-
canEqual
-
hashCode
-
getAmount
The amount of the Quantity. Explicitly set a prefixed column name to avoid name conflicts. -
getMetric
The metric of the Quantity. Explicitly set a prefixed column name to avoid name conflicts.
-