Enum CmpOperator
- java.lang.Object
-
- java.lang.Enum<CmpOperator>
-
- de.aristaflow.adept2.model.orgmodel.CmpOperator
-
- All Implemented Interfaces:
Serializable,Comparable<CmpOperator>
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
CmpOperatorwould be e.g. finding out the data type of an attribute (seeModelExplorer.getAttributeDataType(de.aristaflow.adept2.base.sessionmanagement.SessionToken, EntityType, String)), finding out the data type of an object (seeDataType.getDataTypeForObject(Object)) and usingcanCompare(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)andnegate()will most certainly have to be adapted, too.If new
CmpOperators are added, don't forget to updatenegate(),canCompare(DataType)andcanCompare(DataType, DataType).- Author:
- Patrick Schmidt
-
-
Enum Constant Summary
Enum Constants Enum Constant Description EQUALThe "equal" operator.EQUAL_IGNORECASEA case insensitive version ofEQUAL.GREATER_THANthe "greater than" operator; also allowed in the context of stringsGREATER_THAN_OR_EQUALthe "greater than or equal" operator; also allowed in the context of stringsLESS_THANthe "less than" operator; also allowed in the context of stringsLESS_THAN_OR_EQUALthe "less than or equal" operator; also allowed in the context of stringsLIKEThe "like" operator works like SQL's LIKE operator.LIKE_IGNORECASEA case insensitive version ofLIKE.NOT_EQUALThe "not equal" operator.NOT_EQUAL_IGNORECASEA case insensitive version ofNOT_EQUAL.NOT_LIKEA negatedLIKEoperator.NOT_LIKE_IGNORECASEA case insensitive version ofNOT_LIKE.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanCompare(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.CmpOperatornegate()Returns the negated version of this operator.Stringsymbol()Returns the first (most preferred) symbol for this operator.String[]symbols()Returns an array containing all symbols defined for this operator.static CmpOperatorvalueOf(String name)Returns the enum constant of this type with the specified name.static CmpOperator[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
EQUAL
public static final CmpOperator EQUAL
-
NOT_EQUAL
public static final CmpOperator NOT_EQUAL
-
EQUAL_IGNORECASE
public static final CmpOperator EQUAL_IGNORECASE
A case insensitive version ofEQUAL. This only works on strings, it does not work onnull.
-
NOT_EQUAL_IGNORECASE
public static final CmpOperator NOT_EQUAL_IGNORECASE
A case insensitive version ofNOT_EQUAL. This only works on strings, it does not work onnull.
-
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 negatedLIKEoperator. Only works on strings.
-
LIKE_IGNORECASE
public static final CmpOperator LIKE_IGNORECASE
-
NOT_LIKE_IGNORECASE
public static final CmpOperator NOT_LIKE_IGNORECASE
-
-
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 nameNullPointerException- 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 onEQUALwill returnNOT_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 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
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 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
public static CmpOperator getCmpOperatorFor(String symbol)
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
-
-