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.Object
Class representing time periods like days, months, years.
When introducing newOperators.RelativeDateOperator.TimePeriod
make a new private static implementation, introduce a public static final field inOperators.RelativeDateOperator.TimePeriod
and add it to theTIME_PERIODS
.
-
-
Field Summary
Fields Modifier and Type Field Description static Operators.RelativeDateOperator.TimePeriod
DAYS
Time period representing days.static Operators.RelativeDateOperator.TimePeriod
MONTHS
Time period representing months.protected java.lang.String
name
The display name of time period.static Operators.RelativeDateOperator.TimePeriod
YEARS
Time period representing years.
-
Constructor Summary
Constructors Modifier Constructor Description protected
TimePeriod(java.lang.String name)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.util.Date
calculateDate(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.String
getTimePeriodsAsString()
protected boolean
isMatching(java.lang.String name)
Returns whether the input name matches with the time period.static Operators.RelativeDateOperator.TimePeriod
match(java.lang.String name)
Returns time period matching with the input string.java.lang.String
toString()
-
-
-
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:
toString
in classjava.lang.Object
-
-