public enum CmpOperator extends java.lang.Enum<CmpOperator>
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).
| Enum Constant and Description |
|---|
EQUAL
The "equal" operator.
|
EQUAL_IGNORECASE
A case insensitive version of
EQUAL. |
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.
|
LIKE_IGNORECASE
A case insensitive version of
LIKE. |
NOT_EQUAL
The "not equal" operator.
|
NOT_EQUAL_IGNORECASE
A case insensitive version of
NOT_EQUAL. |
NOT_LIKE
A negated
LIKE operator. |
NOT_LIKE_IGNORECASE
A case insensitive version of
NOT_LIKE. |
| Modifier and Type | Method and 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(java.lang.String symbol)
Returns the
CmpOperator for the given symbol or
null if the symbol is not recognised. |
CmpOperator |
negate()
Returns the negated version of this operator.
|
java.lang.String |
symbol()
Returns the first (most preferred) symbol for this operator.
|
java.lang.String[] |
symbols()
Returns an array containing all symbols defined for this operator.
|
static CmpOperator |
valueOf(java.lang.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.
|
public static final CmpOperator EQUAL
public static final CmpOperator NOT_EQUAL
public static final CmpOperator EQUAL_IGNORECASE
EQUAL. This only works on strings, it does not work on
null.public static final CmpOperator NOT_EQUAL_IGNORECASE
NOT_EQUAL. This only works on strings, it does not work
on null.public static final CmpOperator GREATER_THAN
public static final CmpOperator GREATER_THAN_OR_EQUAL
public static final CmpOperator LESS_THAN
public static final CmpOperator LESS_THAN_OR_EQUAL
public static final CmpOperator LIKE
_ is a
placeholder for exactly one character; % is a placeholder
for an arbitrary number of characters (even zero). Only works on strings.public static final CmpOperator NOT_LIKE
LIKE operator. Only works on strings.public static final CmpOperator LIKE_IGNORECASE
public static final CmpOperator NOT_LIKE_IGNORECASE
public static CmpOperator[] values()
for (CmpOperator c : CmpOperator.values()) System.out.println(c);
public static CmpOperator valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic java.lang.String symbol()
public java.lang.String[] symbols()
public CmpOperator negate()
EQUAL will return NOT_EQUAL.
This method must be updated if a new comparison operator is added!
public boolean canCompare(DataType attributeDataType, DataType valueObjectDataType)
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.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)public boolean canCompare(DataType dataType)
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).dataType - the data type to be testedpublic static CmpOperator getCmpOperatorFor(java.lang.String symbol)
CmpOperator for the given symbol or
null if the symbol is not recognised.symbol - the symbol for which the appropriate CmpOperator
should be returnedCmpOperator for the given symbol or
null if the symbol is not recognised