|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jstatcom.util.Maturity
public final class Maturity
Immutable representation of a maturity. This class is needed by financial
tools. Instances can be created via the constructor or with
valueOf
from a string.
Field Summary | |
---|---|
int |
COUNT
The number of the time units. |
MaturityUnits |
UNIT
Time unit (day, month, year). |
Constructor Summary | |
---|---|
Maturity(int count,
MaturityUnits unit)
Creates a maturity instance. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object o)
Overrides equals to provide logical comparison of two
different Maturity objects. |
int |
hashCode()
Overrides hashCode , because equals was overwritten. |
java.lang.String |
toString()
|
static Maturity |
valueOf(java.lang.String toParse)
Creates a maturity from a string representation. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final int COUNT
public final MaturityUnits UNIT
Constructor Detail |
---|
public Maturity(int count, MaturityUnits unit)
count
- number of time unitsunit
- time unit
java.lang.IllegalArgumentException
- if (unit == null)
or
if (count < 0)
Method Detail |
---|
public static Maturity valueOf(java.lang.String toParse)
x[-,' ']?[DAYS, MONTHS, YEARS]
, where x
is
an int
. Examples are:
As can be seen, days, months, and years can be parsed from either a single character or the full name.
toParse
-
public int hashCode()
hashCode
, because equals was overwritten. The
algorithm was taken from (Joshua Bloch, "Effective Java", Item 8)
.
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
to provide logical comparison of two
different Maturity
objects.
equals
in class java.lang.Object
o
- object to compare with
true
if COUNT
and UNIT
are the same, false
otherwisepublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |