Enum Class IntervalUnit

java.lang.Object
java.lang.Enum<IntervalUnit>
dev.frostlake.executor.expressions.IntervalUnit
All Implemented Interfaces:
Serializable, Comparable<IntervalUnit>, Constable

public enum IntervalUnit extends Enum<IntervalUnit>
The unit of an IntervalExpression. One constant per UNIT, with the many spellings live accepts for each resolved by fromSpelling(java.lang.String): year, y, yy, yyyy, yr and years are one unit, not six.

EVERY SPELLING HERE WAS READ OFF A LIVE ACCOUNT, and the list has holes no rule predicts. Adding one because it looks like its neighbours is how this list goes wrong: a first draft guessed fifteen from the pattern and FOUR were refused live —

   wk  accepted     wks      REFUSED
   sec accepted     ss       REFUSED
   woy accepted     wofy     REFUSED
   msec accepted    msecs    REFUSED
   usec accepted    usecs    REFUSED
   nanosecs accepted   nsecs REFUSED
 

So do not "tidy" or extend this list. Measure the spelling, then add it.

  • Enum Constant Details

  • Method Details

    • values

      public static IntervalUnit[] 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 IntervalUnit 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
    • fromSpelling

      public static IntervalUnit fromSpelling(String text)
      The unit a spelling names, or null when live does not recognise it either.
      Parameters:
      text - the unit word as written, in any case
      Returns:
      the unit, or null when the spelling is not one live accepts
    • isWholeDay

      public boolean isWholeDay()
      Whether this unit measures a WHOLE DAY or more, which decides whether adding it to a DATE leaves a DATE or promotes to TIMESTAMP_NTZ. DAY is the one unit whose answer also depends on which INTERVAL spelling was used — see IntervalExpression.isUnitInString().
      Returns:
      true for year, quarter, month, week and day