Package com.im.df.api.dml
Class Operators.RelativeDateOperator.TimePeriod
- java.lang.Object
-
- com.im.df.api.dml.Operators.RelativeDateOperator.TimePeriod
-
- Enclosing class:
- Operators.RelativeDateOperator
public abstract static class Operators.RelativeDateOperator.TimePeriod extends java.lang.ObjectClass representing time periods like days, months, years.
When introducing newOperators.RelativeDateOperator.TimePeriodmake a new private static implementation, introduce a public static final field inOperators.RelativeDateOperator.TimePeriodand add it to theTIME_PERIODS.
-
-
Field Summary
Fields Modifier and Type Field Description static Operators.RelativeDateOperator.TimePeriodDAYSTime period representing days.static Operators.RelativeDateOperator.TimePeriodMONTHSTime period representing months.protected java.lang.StringnameThe display name of time period.static Operators.RelativeDateOperator.TimePeriodYEARSTime period representing years.
-
Constructor Summary
Constructors Modifier Constructor Description protectedTimePeriod(java.lang.String name)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.util.DatecalculateDate(int before)Calculates a date from the before time and the actual date.static Operators.RelativeDateOperator.TimePeriod[]getTimePeriods()Returns the registered time periods.static java.lang.StringgetTimePeriodsAsString()protected booleanisMatching(java.lang.String name)Returns whether the input name matches with the time period.static Operators.RelativeDateOperator.TimePeriodmatch(java.lang.String name)Returns time period matching with the input string.java.lang.StringtoString()
-
-
-
Field Detail
-
DAYS
public static final Operators.RelativeDateOperator.TimePeriod DAYS
Time period representing days.
-
MONTHS
public static final Operators.RelativeDateOperator.TimePeriod MONTHS
Time period representing months.
-
YEARS
public static final Operators.RelativeDateOperator.TimePeriod YEARS
Time period representing years.
-
name
protected final java.lang.String name
The display name of time period.
-
-
Method Detail
-
getTimePeriodsAsString
public static java.lang.String getTimePeriodsAsString()
-
match
public static Operators.RelativeDateOperator.TimePeriod match(java.lang.String name)
Returns time period matching with the input string.- Parameters:
name- the name of time period.- Returns:
- The TimePeriod when the name matches, null when the name is null or empty or no matching is found.
-
getTimePeriods
public static Operators.RelativeDateOperator.TimePeriod[] getTimePeriods()
Returns the registered time periods.- Returns:
- array containing existing time periods.
-
isMatching
protected boolean isMatching(java.lang.String name)
Returns whether the input name matches with the time period. The actual implementation returns true when the time periods name starts with the input string. It is case insensitive.- Parameters:
name- The string to match with time period.- Returns:
- True when the input String matches with the time period.
-
calculateDate
public abstract java.util.Date calculateDate(int before)
Calculates a date from the before time and the actual date.- Parameters:
before- The number of units to subtract from current time.- Returns:
- The date before.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-