Class Period

  • All Implemented Interfaces:
    java.io.Serializable

    public class Period
    extends java.lang.Object
    implements java.io.Serializable
    Implementation for the period data type "d:period" A period is specified by the period type and an optional expression. The string value is periodType|expression Examples are: none day - one day day|3 - 3 days week - one week week|1 - one week week|2 - two weeks month year monthend quarterend The period type specifies a period implementation. This is registered with this class and is used to when adding the period to a date, handles any processing of the expression, reports if the expression is not required, optional or mandatory. The period data type can be also passed as a Map of keys: periodType and expression.
    Author:
    andyh
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Period​(java.lang.String period)
      Create a period without an accompanying expression.
      Period​(java.util.Map<java.lang.String,​java.lang.String> source)
      Create a period using key-value
    • Constructor Detail

      • Period

        public Period​(java.lang.String period)
        Create a period without an accompanying expression.
        Parameters:
        period - String
      • Period

        public Period​(java.util.Map<java.lang.String,​java.lang.String> source)
        Create a period using key-value
        Parameters:
        source -
    • Method Detail

      • registerProvider

        public static void registerProvider​(PeriodProvider periodProvider)
        Register a provider
        Parameters:
        periodProvider - PeriodProvider
      • getProvider

        public static PeriodProvider getProvider​(java.lang.String periodType)
        Find a provider
        Parameters:
        periodType - String
        Returns:
        the provider
        Throws:
        java.lang.IllegalStateException - of there is no implementation
      • getProviderNames

        public static java.util.Set<java.lang.String> getProviderNames()
        Get the set of registered providers
        Returns:
        - the set of registered providers
      • getPeriodType

        public java.lang.String getPeriodType()
        Returns:
        the periodType
      • getExpression

        public java.lang.String getExpression()
        Returns:
        the expression
      • getNextDate

        public java.util.Date getNextDate​(java.util.Date date)
        Calculate the next date for this period given the a start date.
        Parameters:
        date - Date
        Returns:
        the next date.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

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