Interface EntityCondition
- All Superinterfaces:
IsEmpty
,Serializable
- All Known Implementing Classes:
EntityConditionList
,EntityDateFilterCondition
,EntityExpr
,EntityFieldMap
,EntityNotCondition
,EntityWhereString
Represents a condition expression that can be used in a SQL 'WHERE' clause
which is used to constrain a SQL query.
An EntityCondition can represent various type of constraints, including:
- EntityConditionList: a list of EntityConditions, combined with the operator specified
- EntityExpr: for simple expressions or expressions that combine EntityConditions
- EntityFieldMap: a map of fields where the field (key) equals the value, combined with the operator specified
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(EntityConditionVisitor visitor) Applies a visitor to this condition.void
checkCondition
(ModelEntity modelEntity) Verifies that this condition expression is valid.default boolean
entityMatches
(GenericEntity entity) Checks that this condition expression matches a particular entity.freeze()
Create a Frozen condition expression corresponding to this condition expression.static <R> EntityExpr
makeCondition
(String fieldName, R value) Constructs a condition expression to represent a equality comparison between a field and a value.static <T extends EntityCondition>
EntityConditionList<T>makeCondition
(List<? extends T> conditionList) Constructs a condition expression to represent a conjunction of condition expressionsstatic <T extends EntityCondition>
EntityConditionList<T>makeCondition
(List<? extends T> conditionList, EntityJoinOperator operator) Constructs a condition expression to represent a combination of condition expressions.static EntityFieldMap
makeCondition
(Map<String, ? extends Object> fieldMap) Constructs a condition expression to represent a conjunction of field/value equality comparisons.static <L,
R> EntityFieldMap makeCondition
(Map<String, ? extends Object> fieldMap, EntityComparisonOperator<L, R> compOp, EntityJoinOperator joinOp) Constructs a condition expression to represent a combination of field/value comparisons.static EntityFieldMap
makeCondition
(Map<String, ? extends Object> fieldMap, EntityJoinOperator joinOp) Constructs a condition expression to represent a combination of field/value equality comparisons.static <L,
R, LL, RR>
EntityExprmakeCondition
(L lhs, EntityComparisonOperator<LL, RR> operator, R rhs) Constructs a condition expression to represent a comparison between two elements.static <L,
R> EntityFieldMap makeCondition
(EntityComparisonOperator<L, R> compOp, EntityJoinOperator joinOp, Object... keysValues) Constructs a condition expression to represent a combination of field/value comparisons.static EntityExpr
makeCondition
(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) Constructs a condition expression to represent a combination of two condition expressions.static EntityFieldMap
makeCondition
(EntityJoinOperator joinOp, Object... keysValues) Constructs a condition expression to represent a combination of field/value equality comparisons.static <R extends EntityCondition,
T extends R>
EntityConditionList<R>makeCondition
(EntityJoinOperator operator, T... conditionList) Constructs a condition expression to represent a combination of condition expressions.static <R extends EntityCondition,
T extends R>
EntityConditionList<R>makeCondition
(T... conditionList) Constructs a condition expression to represent a conjunction of condition expressionsstatic EntityDateFilterCondition
makeConditionDate
(String fromDateName, String thruDateName) Constructs a condition expression to filter rows that are currently valid.static EntityFieldMap
makeConditionMap
(Object... keysValues) Constructs a condition expression to represent a conjunction of field/value equality comparisons.static EntityWhereString
makeConditionWhere
(String sqlString) Constructs a condition expression backed by a raw SQL stringdefault String
Dumps the corresponding SQL string without substituting '?' parameters.makeWhereString
(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, Datasource datasourceInfo) Dumps the corresponding SQL string.boolean
mapMatches
(Delegator delegator, Map<String, ? extends Object> map) Checks that this condition expression matches a particular entity.
-
Field Details
-
serialVersionUID
static final long serialVersionUID- See Also:
-
-
Method Details
-
makeCondition
static <L,R, EntityExpr makeConditionLL, RR> (L lhs, EntityComparisonOperator<LL, RR> operator, R rhs) Constructs a condition expression to represent a comparison between two elements.- Parameters:
lhs
- the left hand side elementoperator
- the binary infix operatorrhs
- the right hand side element- Returns:
- a condition expression representing a comparison between two elements
-
makeCondition
Constructs a condition expression to represent a equality comparison between a field and a value.- Parameters:
fieldName
- the name of the field to comparevalue
- the value to find in field- Returns:
- a condition expression representing a equality comparison
-
makeCondition
static EntityExpr makeCondition(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) Constructs a condition expression to represent a combination of two condition expressions.- Parameters:
lhs
- the left hand side conditionoperator
- the binary infix operator used to combinelhs
andrhs
conditionsrhs
- the right hand side condition- Returns:
- a condition expression representing a combination of condition expression
-
makeCondition
@SafeVarargs static <R extends EntityCondition,T extends R> EntityConditionList<R> makeCondition(EntityJoinOperator operator, T... conditionList) Constructs a condition expression to represent a combination of condition expressions.- Parameters:
operator
- the binary infix operator used to join every elements ofconditionList
conditionList
- the list of condition expressions to join- Returns:
- a condition expression representing a combination of condition expressions.
-
makeCondition
@SafeVarargs static <R extends EntityCondition,T extends R> EntityConditionList<R> makeCondition(T... conditionList) Constructs a condition expression to represent a conjunction of condition expressions- Parameters:
conditionList
- the condition expressions to join withEntityOperator.AND
- Returns:
- a condition expression representing a conjunction of condition expressions
-
makeCondition
static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<? extends T> conditionList, EntityJoinOperator operator) Constructs a condition expression to represent a combination of condition expressions.- Parameters:
conditionList
- the list of condition expressions to joinoperator
- the binary infix operator used to join every elements ofconditionList
- Returns:
- a condition expression representing a combination of condition expressions.
-
makeCondition
static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<? extends T> conditionList) Constructs a condition expression to represent a conjunction of condition expressions- Parameters:
conditionList
- the condition expressions to join withEntityOperator.AND
- Returns:
- a condition expression representing a conjunction of condition expressions
-
makeCondition
static <L,R> EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityComparisonOperator<L, R> compOp, EntityJoinOperator joinOp) Constructs a condition expression to represent a combination of field/value comparisons.- Parameters:
fieldMap
- the map associating a field to the value to matchcompOp
- the binary infix operator used to compare the field and the valuejoinOp
- the binary infix operator used to join the field/value comparisons- Returns:
- a condition expression representing a combination of field/value comparisons
-
makeCondition
static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityJoinOperator joinOp) Constructs a condition expression to represent a combination of field/value equality comparisons.- Parameters:
fieldMap
- the map associating a field to the value to match withEntityOperator.EQUALS
joinOp
- the binary infix operator used to join the field/value equality comparisons- Returns:
- a condition expression representing a combination of field/value equality comparisons
-
makeCondition
Constructs a condition expression to represent a conjunction of field/value equality comparisons.- Parameters:
fieldMap
- the map associating a field to the value to match withEntityOperator.EQUALS
- Returns:
- a condition expression representing a conjunction of field/value equality comparisons
-
makeCondition
static <L,R> EntityFieldMap makeCondition(EntityComparisonOperator<L, R> compOp, EntityJoinOperator joinOp, Object... keysValues) Constructs a condition expression to represent a combination of field/value comparisons.- Parameters:
compOp
- the binary infix operator used to compare the field and the valuejoinOp
- the binary infix operator used to join the field/value comparisonskeysValues
- the field/values pairs to match- Returns:
- a condition expression representing a combination of field/value comparisons
-
makeCondition
Constructs a condition expression to represent a combination of field/value equality comparisons.- Parameters:
joinOp
- the binary infix operator used to join the field/value equality comparisonskeysValues
- the field/values pairs to match withEntityOperator.EQUALS
- Returns:
- a condition expression representing a combination of field/value equality comparisons
-
makeConditionMap
Constructs a condition expression to represent a conjunction of field/value equality comparisons.- Parameters:
keysValues
- the field/values pairs to match withEntityOperator.EQUALS
- Returns:
- a condition expression representing a conjunction of field/value equality comparisons
-
makeConditionDate
Constructs a condition expression to filter rows that are currently valid. This means that we remove rows whose from/thru date range does not match the current date. The current date is the one computed when the SQL query is generated.- Parameters:
fromDateName
- the name of the field corresponding to the from datethruDateName
- the name of the field corresponding to the thru date- Returns:
- a condition expression filtering rows that are currently valid
-
makeConditionWhere
Constructs a condition expression backed by a raw SQL string- Parameters:
sqlString
- the SQL string- Returns:
- a raw SQL string condition expression
-
accept
Applies a visitor to this condition.- Parameters:
visitor
- the visitor to be applied
-
makeWhereString
String makeWhereString(ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, Datasource datasourceInfo) Dumps the corresponding SQL string.- Parameters:
modelEntity
- the model of the entityentityConditionParams
- the effective parameters used to substitute '?' parametersdatasourceInfo
- the model of the data source interpreting the SQL- Returns:
- the corresponding SQL string
-
checkCondition
Verifies that this condition expression is valid.- Parameters:
modelEntity
- the model of the entity- Throws:
GenericModelException
- when this condition expression is not valid
-
entityMatches
Checks that this condition expression matches a particular entity.- Parameters:
entity
- the entity to match- Returns:
true
if this condition expression matchesentity
-
mapMatches
Checks that this condition expression matches a particular entity.- Parameters:
delegator
- the delegator used to matchmap
- the entity definition to match- Returns:
true
if this condition expression matchesmap
when usingdelegator
-
freeze
EntityCondition freeze()Create a Frozen condition expression corresponding to this condition expression.- Returns:
- the frozen condition expression
-
makeWhereString
Dumps the corresponding SQL string without substituting '?' parameters.- Returns:
- the corresponding SQL string
-