Enum Class CmpOperator

java.lang.Object
java.lang.Enum<CmpOperator>
de.aristaflow.adept2.model.orgmodel.CmpOperator
All Implemented Interfaces:
Serializable, Comparable<CmpOperator>, java.lang.constant.Constable

public enum CmpOperator extends Enum<CmpOperator>
The comparison operators used within the OrgModelManager to select certain entities based on their attribute values. For each operator one or more symbols are defined. These symbols (if they contain letters) are NOT case sensitive.

A common task in an implementation of the OrgModelManager involving an CmpOperator would be e.g. finding out the data type of an attribute (see ModelExplorer.getAttributeDataType(de.aristaflow.adept2.base.sessionmanagement.SessionToken, EntityType, String)), finding out the data type of an object (see DataType.getDataTypeForObject(Object)) and using canCompare(DataType, DataType) to determine whether a specific operator can be used to compare them.

Every comparison operator must be negatable. This results from the EXCEPT keyword (see Berr05, page 78).

If new DataTypes are added, canCompare(DataType, DataType) and negate() will most certainly have to be adapted, too.

If new CmpOperators are added, don't forget to update negate(), canCompare(DataType) and canCompare(DataType, DataType).

Author:
Patrick Schmidt
  • Enum Constant Details

    • 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 Details

    • values

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