public final class Fiat extends java.lang.Object implements Monetary, java.lang.Comparable<Fiat>, java.io.Serializable
Coin
because of type
safety. Fiat values always come with an attached currency code.
This class is immutable.Modifier and Type | Field and Description |
---|---|
java.lang.String |
currencyCode |
static int |
SMALLEST_UNIT_EXPONENT
The absolute value of exponent of the value of a "smallest unit" in scientific notation.
|
long |
value
The number of smallest units of this monetary value.
|
Modifier and Type | Method and Description |
---|---|
Fiat |
add(Fiat value) |
int |
compareTo(Fiat other) |
long |
divide(Fiat divisor) |
Fiat |
divide(long divisor) |
Fiat[] |
divideAndRemainder(long divisor) |
boolean |
equals(java.lang.Object o) |
java.lang.String |
getCurrencyCode() |
long |
getValue()
Returns the number of "smallest units" of this monetary value.
|
int |
hashCode() |
boolean |
isGreaterThan(Fiat other)
Returns true if the monetary value represented by this instance is greater than that of the given other Fiat,
otherwise false.
|
boolean |
isLessThan(Fiat other)
Returns true if the monetary value represented by this instance is less than that of the given other Fiat,
otherwise false.
|
boolean |
isNegative()
Returns true if and only if this instance represents a monetary value less than zero, otherwise false.
|
boolean |
isPositive()
Returns true if and only if this instance represents a monetary value greater than zero, otherwise false.
|
boolean |
isZero()
Returns true if and only if this instance represents zero monetary value, otherwise false.
|
long |
longValue()
Returns the number of "smallest units" of this monetary value.
|
Fiat |
multiply(long factor) |
Fiat |
negate() |
static Fiat |
parseFiat(java.lang.String currencyCode,
java.lang.String str)
Parses an amount expressed in the way humans are used to.
|
static Fiat |
parseFiatInexact(java.lang.String currencyCode,
java.lang.String str)
Parses an amount expressed in the way humans are used to.
|
int |
signum() |
int |
smallestUnitExponent()
Returns the absolute value of exponent of the value of a "smallest unit" in scientific notation.
|
Fiat |
subtract(Fiat value) |
java.lang.String |
toFriendlyString()
Returns the value as a 0.12 type string.
|
java.lang.String |
toPlainString()
Returns the value as a plain string.
|
java.lang.String |
toString() |
static Fiat |
valueOf(java.lang.String currencyCode,
long value) |
public static final int SMALLEST_UNIT_EXPONENT
public final long value
public final java.lang.String currencyCode
public static Fiat valueOf(java.lang.String currencyCode, long value)
public int smallestUnitExponent()
Monetary
smallestUnitExponent
in interface Monetary
public long getValue()
public java.lang.String getCurrencyCode()
public static Fiat parseFiat(java.lang.String currencyCode, java.lang.String str)
Parses an amount expressed in the way humans are used to.
This takes string in a format understood by BigDecimal.BigDecimal(String)
, for example "0", "1", "0.10",
"1.23E3", "1234.5E-5".
java.lang.IllegalArgumentException
- if you try to specify more than 4 digits after the comma, or a value out of range.public static Fiat parseFiatInexact(java.lang.String currencyCode, java.lang.String str)
Parses an amount expressed in the way humans are used to. The amount is cut to 4 digits after the comma.
This takes string in a format understood by BigDecimal.BigDecimal(String)
, for example "0", "1", "0.10",
"1.23E3", "1234.5E-5".
java.lang.IllegalArgumentException
- if you try to specify a value out of range.public Fiat multiply(long factor)
public Fiat divide(long divisor)
public Fiat[] divideAndRemainder(long divisor)
public long divide(Fiat divisor)
public boolean isPositive()
public boolean isNegative()
public boolean isZero()
public boolean isGreaterThan(Fiat other)
public boolean isLessThan(Fiat other)
public Fiat negate()
public long longValue()
value
directly.public java.lang.String toFriendlyString()
public java.lang.String toPlainString()
Returns the value as a plain string. The result is unformatted with no trailing zeroes. For instance, a value of 150000 "smallest units" gives an output string of "0.0015".
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object