Enum Class CmpOperator
- All Implemented Interfaces:
Serializable,Comparable<CmpOperator>,java.lang.constant.Constable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe "equal" operator.A case insensitive version ofEQUAL.the "greater than" operator; also allowed in the context of stringsthe "greater than or equal" operator; also allowed in the context of stringsthe "less than" operator; also allowed in the context of stringsthe "less than or equal" operator; also allowed in the context of stringsThe "like" operator works like SQL's LIKE operator.A case insensitive version ofLIKE.The "not equal" operator.A case insensitive version ofNOT_EQUAL.A negatedLIKEoperator.A case insensitive version ofNOT_LIKE. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanCompare(DataType dataType) Returns whether this comparison operator can generally work on the given data type.booleancanCompare(DataType attributeDataType, DataType valueObjectDataType) Returns whether this operator can compare the two given data types.static CmpOperatorgetCmpOperatorFor(String symbol) Returns theCmpOperatorfor the given symbol ornullif the symbol is not recognised.negate()Returns the negated version of this operator.symbol()Returns the first (most preferred) symbol for this operator.String[]symbols()Returns an array containing all symbols defined for this operator.static CmpOperatorReturns the enum constant of this class with the specified name.static CmpOperator[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
EQUAL
-
NOT_EQUAL
-
EQUAL_IGNORECASE
A case insensitive version ofEQUAL. This only works on strings, it does not work onnull. -
NOT_EQUAL_IGNORECASE
A case insensitive version ofNOT_EQUAL. This only works on strings, it does not work onnull. -
GREATER_THAN
the "greater than" operator; also allowed in the context of strings -
GREATER_THAN_OR_EQUAL
the "greater than or equal" operator; also allowed in the context of strings -
LESS_THAN
the "less than" operator; also allowed in the context of strings -
LESS_THAN_OR_EQUAL
the "less than or equal" operator; also allowed in the context of strings -
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
A negatedLIKEoperator. Only works on strings. -
LIKE_IGNORECASE
-
NOT_LIKE_IGNORECASE
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
symbol
Returns the first (most preferred) symbol for this operator.- Returns:
- the first (most preferred) symbol for this operator
-
symbols
Returns an array containing all symbols defined for this operator.- Returns:
- an array containing all symbols defined for this operator
-
negate
Returns the negated version of this operator. E.g. calling this method onEQUALwill returnNOT_EQUAL.This method must be updated if a new comparison operator is added!
- Returns:
- the negated version of this operator
-
canCompare
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 beDataType.NULL. The right-hand data type should be the data type of the value object orDataType.NULLif the value object itself isnull. At the time of writing, onlyEQUALandNOT_EQUALcan compare anull-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 orDataType.NULL)- Returns:
- whether this operator can compare the two given data types
-
canCompare
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 isDataType.NULLthis method will determine if the operator can deal withnullvalues (at the time of writing, onlyEQUALandNOT_EQUALcan do that).- Parameters:
dataType- the data type to be tested- Returns:
- whether this comparison operator can generally work on the given data type
-
getCmpOperatorFor
Returns theCmpOperatorfor the given symbol ornullif the symbol is not recognised.- Parameters:
symbol- the symbol for which the appropriateCmpOperatorshould be returned- Returns:
- the
CmpOperatorfor the given symbol ornullif the symbol is not recognised
-