Enum Class PredefinedDateRange

java.lang.Object
java.lang.Enum<PredefinedDateRange>
com.jbstrap.ui.components.form.base.PredefinedDateRange
All Implemented Interfaces:
Serializable, Comparable<PredefinedDateRange>, Constable

public enum PredefinedDateRange extends Enum<PredefinedDateRange>

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:
  • Enum Constant Details

    • TODAY

      public static final PredefinedDateRange TODAY
      The current day. This range is used to filter on the current day, between 12 AM to 12 PM.
    • YESTERDAY

      public static final PredefinedDateRange YESTERDAY
      The previous day. This range is used to filter to the previous day
    • CURRENT_WEEK

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange 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

      public static final PredefinedDateRange CUSTOM
      Custom range, which can be created by using the addCustomRange(String, String, Function, Function) method.
  • Method Details

    • values

      public static PredefinedDateRange[] 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

      public static PredefinedDateRange valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • fromName

      protected static PredefinedDateRange fromName(String name)
      Parameters:
      name - The name of the range
      Returns:
      The enum value or null if not found
    • getRangeByName

      public static PredefinedRange<Date> getRangeByName(String name)
      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 application
      title - The title of the range, that the user will see on the interface. If null, the range's name will be displayed
      startDate - 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 date
      endDate - 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 is null