Enum CmpOperator

    • Enum Constant Detail

      • EQUAL

        public static final CmpOperator EQUAL
        The "equal" operator. EQUAL and NOT_EQUAL are the only comparison operators that can work on null values.
      • NOT_EQUAL

        public static final CmpOperator NOT_EQUAL
        The "not equal" operator. EQUAL and NOT_EQUAL are the only comparison operators that can work on null values.
      • EQUAL_IGNORECASE

        public static final CmpOperator EQUAL_IGNORECASE
        A case insensitive version of EQUAL. This only works on strings, it does not work on null.
      • NOT_EQUAL_IGNORECASE

        public static final CmpOperator NOT_EQUAL_IGNORECASE
        A case insensitive version of NOT_EQUAL. This only works on strings, it does not work on null.
      • GREATER_THAN

        public static final CmpOperator GREATER_THAN
        the "greater than" operator; also allowed in the context of strings
      • GREATER_THAN_OR_EQUAL

        public static final CmpOperator GREATER_THAN_OR_EQUAL
        the "greater than or equal" operator; also allowed in the context of strings
      • LESS_THAN

        public static final CmpOperator LESS_THAN
        the "less than" operator; also allowed in the context of strings
      • LESS_THAN_OR_EQUAL

        public static final CmpOperator LESS_THAN_OR_EQUAL
        the "less than or equal" operator; also allowed in the context of strings
      • LIKE

        public static final CmpOperator LIKE
        The "like" operator works like SQL's LIKE operator. _ is a placeholder for exactly one character; % is a placeholder for an arbitrary number of characters (even zero). Only works on strings.
      • NOT_LIKE

        public static final CmpOperator NOT_LIKE
        A negated LIKE operator. Only works on strings.
      • LIKE_IGNORECASE

        public static final CmpOperator LIKE_IGNORECASE
        A case insensitive version of LIKE. When not using any placeholders this operator works like a case insensitive EQUAL. Only works on strings.
      • NOT_LIKE_IGNORECASE

        public static final CmpOperator NOT_LIKE_IGNORECASE
        A case insensitive version of NOT_LIKE. When not using any placeholders this operator works like a case insensitive NOT_EQUAL. Only works on strings.
    • Method Detail

      • values

        public static CmpOperator[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CmpOperator c : CmpOperator.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CmpOperator valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
        NullPointerException - if the argument is null
      • symbol

        public String symbol()
        Returns the first (most preferred) symbol for this operator.
        Returns:
        the first (most preferred) symbol for this operator
      • symbols

        public String[] symbols()
        Returns an array containing all symbols defined for this operator.
        Returns:
        an array containing all symbols defined for this operator
      • negate

        public CmpOperator negate()
        Returns the negated version of this operator. E.g. calling this method on EQUAL will return NOT_EQUAL.

        This method must be updated if a new comparison operator is added!

        Returns:
        the negated version of this operator
      • canCompare

        public boolean canCompare​(DataType attributeDataType,
                                  DataType valueObjectDataType)
        Returns whether this operator can compare the two given data types. The left-hand data type should be the attribute's data type and must never be DataType.NULL. The right-hand data type should be the data type of the value object or DataType.NULL if the value object itself is null. At the time of writing, only EQUAL and NOT_EQUAL can compare a null-value to the value of an attribute.
        Parameters:
        attributeDataType - the left-hand data type (which should be the attribute data type)
        valueObjectDataType - the right-hand data type (which should be the value object's data type or DataType.NULL)
        Returns:
        whether this operator can compare the two given data types
      • canCompare

        public boolean canCompare​(DataType dataType)
        Returns whether this comparison operator can generally work on the given data type. If it can, this at least guarantees that it can compare two values of this same type. If the parameter is DataType.NULL this method will determine if the operator can deal with null values (at the time of writing, only EQUAL and NOT_EQUAL can do that).
        Parameters:
        dataType - the data type to be tested
        Returns:
        whether this comparison operator can generally work on the given data type
      • getCmpOperatorFor

        public static CmpOperator getCmpOperatorFor​(String symbol)
        Returns the CmpOperator for the given symbol or null if the symbol is not recognised.
        Parameters:
        symbol - the symbol for which the appropriate CmpOperator should be returned
        Returns:
        the CmpOperator for the given symbol or null if the symbol is not recognised