Enum Class PredefinedDateRange
- All Implemented Interfaces:
Serializable
,Comparable<PredefinedDateRange>
,Constable
Predefined date ranges, used for filtering.
The values in this enum are predefined date ranges, used for filtering. The JBStrap frameworks supplies these basic ranges, but a custom one can be created as well. These predefined ranges can be referenced by their names, and the custom ranges, created by the developer(s) can be referenced by using the CUSTOM range(s).
A custom range can be created by using the addCustomRange(String, String, Function, Function)
method. For more information about this custom implementation, see the description of the method.
The specific predefined ranges can be retrieved by using the getRangeByName(String)
method. The method can retrieve both the default ranges, and the custom ranges. The ranges can be specified by their names.
- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionThe current month.The current week.The current year.Custom range, which can be created by using theaddCustomRange(String, String, Function, Function)
method.The first quarter.The fourth quarter.The previous month.The previous quarter.The previous week.The previous year.The second quarter.The third quarter.The current day.The previous day. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addCustomRange
(String name, String title, Function<Date, Date> startDate, Function<Date, Date> endDate) Adds a custom range to the enum.protected static PredefinedDateRange
static PredefinedRange<Date>
getRangeByName
(String name) Gets the POJO class of the specified rangestatic PredefinedDateRange
Returns the enum constant of this class with the specified name.static PredefinedDateRange[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
TODAY
The current day. This range is used to filter on the current day, between 12 AM to 12 PM. -
YESTERDAY
The previous day. This range is used to filter to the previous day -
CURRENT_WEEK
The current week. This range is used to filter between the current week's first day and last day. The first day is determined by the Java virtual machine's language settings. -
LAST_WEEK
The previous week. This range is used to filter between the previous week's first day and last day. The first day is determined by the Java virtual machine's language settings. -
CURRENT_MONTH
The current month. The range is used to filter between the first day of the month and last day of the month. -
LAST_MONTH
The previous month. The range is used to filter between the first day of the previous month and last day of the previous month. -
LAST_QUARTER
The previous quarter. The range is used to filter between the first day of the previous quarter and the last day of the previous quarter. -
FIRST_QUATER
The first quarter. The range is used to filter to the current year's first quarter. First quarter: January 1st — March 31st. -
SECOND_QUARTER
The second quarter. The range is used to filter to the current year's second quarter. Second quarter: April 1st — June 30th. -
THIRD_QUARTER
The third quarter. The range is used to filter to the current year's third quarter. Third quarter: July 1st — September 30th. -
FOURTH_QUARTER
The fourth quarter. The range is used to filter to the current year's fourth quarter. Fourth quarter: October 1st — December 31st. -
CURRENT_YEAR
The current year. The range is used to filter between the first day of the current year and the last day of the current year. -
LAST_YEAR
The previous year. The range is used to filter between the first day of the previous year and the last day of the previous year. -
CUSTOM
Custom range, which can be created by using theaddCustomRange(String, String, Function, Function)
method.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
fromName
- Parameters:
name
- The name of the range- Returns:
- The enum value or
null
if not found
-
getRangeByName
Gets the POJO class of the specified range- Parameters:
name
- The name of the range- Returns:
- The POJO class of the specified range or
null
, if not found
-
addCustomRange
public static void addCustomRange(String name, String title, Function<Date, Date> startDate, Function<Date, Date> endDate) Adds a custom range to the enum. This range can be used anywhere within the program.- Parameters:
name
- The name of the range, must be unique within the applicationtitle
- The title of the range, that the user will see on the interface. Ifnull
, the range's name will be displayedstartDate
- Function determining the starting date of the range. The function will receive the actual date in the parameter, which can be used to define the starting dateendDate
- Function determining the ending date of the range. The function will receive the actual date in the parameter, which can be used to define the ending date- Throws:
NullPointerException
- If the name, or either date isnull
-