Documentation of 'com.jstatcom.util.Maturity' Java class
Maturity
com.jstatcom.util

Class Maturity

  • All Implemented Interfaces:
    java.io.Serializable


    public final class Maturity
    extends java.lang.Object
    implements java.io.Serializable
    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.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      int COUNT
      The number of the time units.
      MaturityUnits UNIT
      Time unit (day, month, year).
    • Constructor Summary

      Constructors 
      Constructor and Description
      Maturity(int count, MaturityUnits unit)
      Creates a maturity instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      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

      • COUNT

        public final int COUNT
        The number of the time units.
      • UNIT

        public final MaturityUnits UNIT
        Time unit (day, month, year).
    • Constructor Detail

      • Maturity

        public Maturity(int count,
                        MaturityUnits unit)
        Creates a maturity instance.
        Parameters:
        count - number of time units
        unit - time unit
        Throws:
        java.lang.IllegalArgumentException - if (unit == null) or if (count < 0)
    • Method Detail

      • valueOf

        public static Maturity valueOf(java.lang.String toParse)
        Creates a maturity from a string representation. The general format is x[-,' ']?[DAYS, MONTHS, YEARS], where x is an int. Examples are:
        • "30 d", "30 days", "30 day", "2d", "6-d"
        • "6 m", "6 month", "6 months", "2m", "6-months"
        • "3 y", "3 year", "3 years", "2y", "6-year"

        As can be seen, days, months, and years can be parsed from either a single character or the full name.

        Parameters:
        toParse -
        Returns:
        maturity instance
      • hashCode

        public int hashCode()
        Overrides hashCode, because equals was overwritten. The algorithm was taken from (Joshua Bloch, "Effective Java", Item 8) .
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hash code
      • equals

        public boolean equals(java.lang.Object o)
        Overrides equals to provide logical comparison of two different Maturity objects.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - object to compare with
        Returns:
        true if COUNT and UNIT are the same, false otherwise
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.