EAF 7.6 Implementation

com.lutris.util
Class Currency

java.lang.Object
  extended by java.lang.Number
      extended by java.math.BigDecimal
          extended by com.lutris.util.Currency
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<java.math.BigDecimal>

public class Currency
extends java.math.BigDecimal

Object to store and manipulate money.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.math.BigDecimal
ONE, ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_HALF_DOWN, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_UNNECESSARY, ROUND_UP, TEN, ZERO
 
Constructor Summary
Currency()
          Construct a Currency object of value zero.
Currency(java.math.BigDecimal value)
          Construct a Currency object from a BigDecimal or Currency object.
Currency(double value)
          Construct a Currency object from a double.
Currency(float value)
          Construct a Currency object from a float.
Currency(java.lang.String value)
          Construct a Currency object from a String.
 
Method Summary
 Currency absCurrency()
          Returns a Currency whose value is the absolute value of this number.
 Currency add(Currency val)
          Returns a Currency whose value is (this + val).
 Currency divide(Currency val)
          Returns a Currency whose value is (this / val).
 Currency divide(int val)
          Returns a Currency whose value is (this / val).
 boolean equals(double value)
          Check if equal to a double value.
 boolean equals(float value)
          Check if equal to a float value.
 Currency multiply(Currency val)
          Returns a Currency whose value is (this * val)
 Currency multiply(int val)
          Returns a Currency whose value is (this * val)
 Currency negateCurrency()
          Returns a Currency whose value is -1 * this.
 Currency subtract(Currency val)
          Returns a Currency whose value is (this - val).
 java.lang.String toString()
          Convert to string with two decimals.
 
Methods inherited from class java.math.BigDecimal
abs, abs, add, add, byteValueExact, compareTo, divide, divide, divide, divide, divide, divide, divideAndRemainder, divideAndRemainder, divideToIntegralValue, divideToIntegralValue, doubleValue, equals, floatValue, hashCode, intValue, intValueExact, longValue, longValueExact, max, min, movePointLeft, movePointRight, multiply, multiply, negate, negate, plus, plus, pow, pow, precision, remainder, remainder, round, scale, scaleByPowerOfTen, setScale, setScale, setScale, shortValueExact, signum, stripTrailingZeros, subtract, subtract, toBigInteger, toBigIntegerExact, toEngineeringString, toPlainString, ulp, unscaledValue, valueOf, valueOf, valueOf
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Currency

public Currency()
Construct a Currency object of value zero.


Currency

public Currency(java.math.BigDecimal value)
Construct a Currency object from a BigDecimal or Currency object. A null value result in an object containing zero.


Currency

public Currency(double value)
Construct a Currency object from a double.


Currency

public Currency(float value)
Construct a Currency object from a float.


Currency

public Currency(java.lang.String value)
Construct a Currency object from a String.

Method Detail

equals

public boolean equals(float value)
Check if equal to a float value.


equals

public boolean equals(double value)
Check if equal to a double value.


add

public Currency add(Currency val)
Returns a Currency whose value is (this + val).


subtract

public Currency subtract(Currency val)
Returns a Currency whose value is (this - val).


multiply

public Currency multiply(Currency val)
Returns a Currency whose value is (this * val)


multiply

public Currency multiply(int val)
Returns a Currency whose value is (this * val)


divide

public Currency divide(Currency val)
                throws java.lang.ArithmeticException,
                       java.lang.IllegalArgumentException
Returns a Currency whose value is (this / val).

Throws:
java.lang.ArithmeticException
java.lang.IllegalArgumentException

divide

public Currency divide(int val)
                throws java.lang.ArithmeticException,
                       java.lang.IllegalArgumentException
Returns a Currency whose value is (this / val).

Throws:
java.lang.ArithmeticException
java.lang.IllegalArgumentException

absCurrency

public Currency absCurrency()
Returns a Currency whose value is the absolute value of this number.


negateCurrency

public Currency negateCurrency()
Returns a Currency whose value is -1 * this.


toString

public java.lang.String toString()
Convert to string with two decimals.

Overrides:
toString in class java.math.BigDecimal

EAF 7.6 Implementation