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
CmpOperator
would 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
DataType
s are added,canCompare(DataType, DataType)
andnegate()
will most certainly have to be adapted, too.If new
CmpOperator
s are added, don't forget to updatenegate()
,canCompare(DataType)
andcanCompare(DataType, DataType)
.- Author:
- Patrick Schmidt
-
-
Enum Constant Summary
Enum Constants Enum Constant Description EQUAL
The "equal" operator.EQUAL_IGNORECASE
A case insensitive version ofEQUAL
.GREATER_THAN
the "greater than" operator; also allowed in the context of stringsGREATER_THAN_OR_EQUAL
the "greater than or equal" operator; also allowed in the context of stringsLESS_THAN
the "less than" operator; also allowed in the context of stringsLESS_THAN_OR_EQUAL
the "less than or equal" operator; also allowed in the context of stringsLIKE
The "like" operator works like SQL's LIKE operator.LIKE_IGNORECASE
A case insensitive version ofLIKE
.NOT_EQUAL
The "not equal" operator.NOT_EQUAL_IGNORECASE
A case insensitive version ofNOT_EQUAL
.NOT_LIKE
A negatedLIKE
operator.NOT_LIKE_IGNORECASE
A case insensitive version ofNOT_LIKE
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canCompare(DataType dataType)
Returns whether this comparison operator can generally work on the given data type.boolean
canCompare(DataType attributeDataType, DataType valueObjectDataType)
Returns whether this operator can compare the two given data types.static CmpOperator
getCmpOperatorFor(String symbol)
Returns theCmpOperator
for the given symbol ornull
if the symbol is not recognised.CmpOperator
negate()
Returns the negated version of this operator.String
symbol()
Returns the first (most preferred) symbol for this operator.String[]
symbols()
Returns an array containing all symbols defined for this operator.static CmpOperator
valueOf(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 negatedLIKE
operator. 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 onEQUAL
will 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.NULL
if the value object itself isnull
. At the time of writing, onlyEQUAL
andNOT_EQUAL
can 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.NULL
this method will determine if the operator can deal withnull
values (at the time of writing, onlyEQUAL
andNOT_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 theCmpOperator
for the given symbol ornull
if the symbol is not recognised.- Parameters:
symbol
- the symbol for which the appropriateCmpOperator
should be returned- Returns:
- the
CmpOperator
for the given symbol ornull
if the symbol is not recognised
-
-