Enum Class Comparison

java.lang.Object
java.lang.Enum<Comparison>
com.ultikits.ultitools.entities.Comparison
All Implemented Interfaces:
Serializable, Comparable<Comparison>, java.lang.constant.Constable

public enum Comparison extends Enum<Comparison>
How a WhereCondition compares a stored column with its value.

The comparison means the same in getAll, exist, page, del and updateIf of the SQLite, MySQL and JSON data operators, and no table is changed to make it hold. DataOperator#getLike and Query#like are separate pattern operators and do not use this enum.

Version:
1.0.0
Author:
wisdomme
  • Enum Constant Details

    • EQUAL

      public static final Comparison EQUAL
      The stored value equals the value. Its meaning is unchanged; in DataOperator#updateIf a null value means the column is unset (IS NULL).
    • GREATER

      public static final Comparison GREATER
      The stored value is greater than the value.

      On a byte, short, int, long, float or double field, or its wrapper, the two are compared as numbers of that type. Pass the value as a number of that type (for example 10, not "10"): a text value is not converted, and MySQL compares it with a default text column as text, so "10" sorts below "2". On SQLite the comparison holds also in a column left on the default VARCHAR(255) type, with 64-bit integer precision, and compares a stored value the way it reads back: a float such as 0.1f is neither greater nor less than the same value, and a double that needs 16 or 17 significant digits is stored and compared with 15. A number that agrees with a stored float to 15 significant digits but differs after them compares as equal to it; pass a float value for a float field. That holds for a value that is a finite number; an infinite value, a number beyond the range of a double and text are compared as bound, and a NaN value matches no row. On MySQL such a default text column is compared the way MySQL compares text with a number, in double precision, so whole numbers beyond plus or minus 9,007,199,254,740,992 (2^53) compare approximately; declare the column with a numeric type (for example BIGINT) for exact results there. On JSON the values are compared as double, also approximate beyond plus or minus 9,007,199,254,740,992, and an infinite or NaN value throws IllegalArgumentException, because it cannot be written as JSON. A field of any other type is compared as the database compares the stored text.

    • LESS

      public static final Comparison LESS
      The stored value is less than the value. It follows the same rules as GREATER: typed numeric comparison on numeric fields, for a value passed as a number of the field's type (on SQLite also in default text columns, with 64-bit integer precision and as the stored value reads back; on MySQL default text columns and on JSON in double precision, approximate beyond plus or minus 9,007,199,254,740,992), and the database's text comparison otherwise.
    • INCLUDE

      public static final Comparison INCLUDE
      The stored text contains the value.

      The value is matched literally as text, on SQLite, MySQL and JSON alike: percent, underscore, exclamation mark and backslash are ordinary characters, not wildcards or escapes. Letter case and accents follow the backend: SQLite ignores the case of ASCII letters only; MySQL compares under the utf8mb3_general_ci collation of the tables the framework creates, which ignores case and accents, so e matches é; JSON compares exactly.

    • STARTSWITH

      public static final Comparison STARTSWITH
      The stored text starts with the value, matched literally as text with the same rules as INCLUDE.
    • ENDSWITH

      public static final Comparison ENDSWITH
      The stored text ends with the value, matched literally as text with the same rules as INCLUDE.
  • Constructor Details

    • Comparison

      private Comparison()
  • Method Details

    • values

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