Dealing with Conditions¶
Conditions passed to a Custom wrapper as arguments for its run, delete
and update methods (see sections Extending AbstractCustomWrapper and
Overriding AbstractCustomWrapper) come encapsulated in instances of
CustomWrapperConditionHolder
. The objects of this class contain two
versions of the conditions passed to the Custom wrapper:
A simplified version, available by calling the
getConditionMap
method. This version consists on an association betweenCustomWrapperFieldExpressions
andObjects
. For example, if we have a condition map like{ FIELD1 - 100; FIELD2 - 'foo' }
, it means that the condition passed to the CUSTOM wrapper isFIELD1 = 100 AND FIELD2 = 'foo'
. For a condition to be available as a map, it must match the patternFIELD_1 = value [AND FIELD_N = value]*
, in other case thegetConditionMap
method will return null. Conversion to map can be forced by calling thegetConditionMap(boolean force)
method, passing true as the value for force. Take into account that in this case the returned map may not be equivalent to the original condition.A
CustomWrapperCondition
instance. This version is available by calling thegetComplexCondition
method.
CustomWrapperCondition is the superclass of all the types of conditions that can be supported by a Custom wrapper:
CustomWrapperSimpleCondition
represents a simple condition. It holds the left expression (aCustomWrapperExpression
object), an operator and the right expression (an array ofCustomWrapperExpression
objects). The right expression is stored in array, which usually contains only one expression.CustomWrapperAndCondition
represents a series of conditions joined by the AND operator. It holds a list ofCustomWrapperCondition
objects.CustomWrapperOrCondition
represents a series of conditions joined by the OR operator. It holds a list ofCustomWrapperCondition
objects.CustomWrapperNotCondition
represents a negated condition. It holds aCustomWrapperCondition
.
CustomWrapperExpression is the superclass of all the types of expressions supported by a Custom wrapper:
CustomWrapperFieldExpression
. This is the most common type of expression in a condition’s left side. See section Overriding AbstractCustomWrapper for details.CustomWrapperSimpleExpression
. This kind of expression has a type (one of the types defined injava.sql.Types
) and a value.CustomWrapperFunctionExpression
. Represents a function with parameters. This type of expression has a name, an optional modifier (ALL
orDISTINCT
), a list of parameters (instances ofCustomWrapperFunctionParameter
) and the property of being an aggregation function or not. ACustomWrapperFunctionParameter
contains a list ofCustomWrapperExpressions
.CustomWrapperConditionExpression
. Represents a condition parameter in aCASE
function. Contains aCustomWrapperCondition
.CustomWrapperArrayExpression
. Contains a list ofCustomWrapperExpressions
, all of the same kind.CustomWrapperRegisterExpression
. Contains a list ofCustomWrapperExpressions
of any kind.