@Embeddable public final class Quantity extends Object
Constructor and Description |
---|
Quantity() |
Modifier and Type | Method and Description |
---|---|
Quantity |
add(Quantity other)
Adds the given
Quantity to the current one. |
boolean |
equals(Object o) |
BigDecimal |
getAmount()
The amount of the Quantity.
|
Metric |
getMetric()
The metric of the Quantity.
|
int |
hashCode() |
boolean |
isCompatibleWith(Metric metric)
|
boolean |
isGreaterThan(Quantity other)
Returns whether the given
Quantity is greater than the current one. |
boolean |
isGreaterThanOrEqualTo(Quantity other)
Returns whether the given
Quantity is greater than or equal to the current one. |
boolean |
isLessThan(Quantity other)
Returns whether the given
Quantity is less than the current one. |
boolean |
isNegative()
Returns whether the current
Quantity is negative. |
boolean |
isZeroOrNegative() |
static Quantity |
of(BigDecimal amount,
Metric metric)
|
static Quantity |
of(double amount)
Creates a new
Quantity of the given amount. |
static Quantity |
of(double amount,
Metric metric)
|
static Quantity |
of(long amount)
Creates a new
Quantity of the given amount. |
static Quantity |
of(long amount,
Metric metric)
|
Quantity |
subtract(Quantity other)
Subtracts the given Quantity from the current one.
|
String |
toString() |
Quantity |
toZero()
|
@Generated(value="lombok") Quantity()
public static Quantity of(long amount)
Quantity
of the given amount. Defaults the metric to .amount
- must not be null.public static Quantity of(double amount)
Quantity
of the given amount. Defaults the metric to .amount
- must not be null.public static Quantity of(long amount, Metric metric)
amount
- must not be null.metric
- must not be null.public static Quantity of(double amount, Metric metric)
amount
- must not be null.metric
- must not be null.public static Quantity of(BigDecimal amount, Metric metric)
amount
- must not be null.metric
- must not be null.public boolean isCompatibleWith(Metric metric)
metric
- must not be null.public Quantity add(Quantity other)
Quantity
to the current one.other
- the Quantity
to add. The given Quantity
's Metric
must be compatible with the
current one.isCompatibleWith(Metric)
public Quantity subtract(Quantity other)
other
- the Quantity
to add. The given Quantity
's Metric
must be compatible with the
current one.isCompatibleWith(Metric)
public boolean isLessThan(Quantity other)
Quantity
is less than the current one.other
- must not be null. The given Quantity
's Metric
must be compatible with the
current one.isCompatibleWith(Metric)
public boolean isGreaterThan(Quantity other)
Quantity
is greater than the current one.other
- must not be null. The given Quantity
's Metric
must be compatible with the
current one.isCompatibleWith(Metric)
public boolean isGreaterThanOrEqualTo(Quantity other)
Quantity
is greater than or equal to the current one.other
- must not be null. The given Quantity
's Metric
must be compatible with the
current one.isCompatibleWith(Metric)
public boolean isNegative()
Quantity
is negative.public boolean isZeroOrNegative()
public Quantity toZero()
@NonNull @Generated(value="lombok") public BigDecimal getAmount()
@NonNull @Generated(value="lombok") public Metric getMetric()
@Generated(value="lombok") public boolean equals(Object o)
@Generated(value="lombok") public int hashCode()
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.