net.lessy.util.type
Class Amount<T extends Amount<T>>
java.lang.Object
net.lessy.util.type.Amount<T>
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- Money, Percentage, Quantity
public abstract class Amount<T extends Amount<T>>
- extends Object
- implements Serializable
General class to represent a number. Internally a BigDecimal is used.
- Author:
- Hans Lesmeister
- See Also:
- Serialized Form
Amount
protected Amount(BigDecimal value,
int decimalPlaces)
Amount
protected Amount(BigDecimal value)
getValue
public BigDecimal getValue()
subtract
public T subtract(Amount<T> amount)
- Subtract an amount from this Amount
- Parameters:
amount - Amount to subtract. If null, zero is subtracted
- Returns:
- The new amount
- See Also:
BigDecimal.subtract(java.math.BigDecimal)
add
public T add(Amount<T> amount)
- Add an amount to this Amount
- Parameters:
amount - Amount to add. If null, zero is added
- Returns:
- The new amount
- See Also:
BigDecimal.add(java.math.BigDecimal)
divideBy
public T divideBy(Amount<T> amount)
divideBy
public T divideBy(int amount)
multiplyWith
public T multiplyWith(Amount<T> amount)
createInstance
public final T createInstance(BigDecimal amount)
equals
public boolean equals(Object o)
- Overrides:
equals in class Object
hashCode
public int hashCode()
- Overrides:
hashCode in class Object
toString
public String toString()
- Overrides:
toString in class Object
Copyright © 2012. All Rights Reserved.