-
- All Known Subinterfaces:
AttributeCondition<T>
,Condition.Combination
,CustomCondition
,SelectCondition
,UpdateCondition
- All Known Implementing Classes:
AbstractCondition
public interface Condition
Specifies a query condition. A factory class forCondition
and it's descendants.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Condition.Combination
An interface encapsulating a combination of Condition objects, that should be either AND'ed or OR'ed together in a query context
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Condition.Combination
and(Condition... conditions)
Returns a new Combination instance, combining this condition with the given one, AND'ing together.List<Attribute<?>>
attributes()
static Condition.Combination
combination(Conjunction conjunction, Condition... conditions)
Initializes a newCondition.Combination
instancestatic Condition.Combination
combination(Conjunction conjunction, Collection<Condition> conditions)
Initializes a newCondition.Combination
instancestatic Condition
condition(EntityType entityType)
Creates aCondition
instance specifying all entities of the type identified byentityType
static Condition
condition(Key key)
Creates aCondition
based on the given keystatic Condition
condition(Collection<Key> keys)
Creates aCondition
based on the given keys, assuming they are all based on the same attributes.static CustomCondition
customCondition(ConditionType conditionType)
Creates a newCustomCondition
based on the condition of the given typestatic CustomCondition
customCondition(ConditionType conditionType, List<Attribute<?>> attributes, List<Object> values)
Creates a newCustomCondition
based on the condition of the given typeEntityType
entityType()
Condition.Combination
or(Condition... conditions)
Returns a new Combination instance, combining this condition with the given one, OR'ing together.SelectCondition.Builder
selectBuilder()
String
toString(EntityDefinition definition)
Returns a string representing this condition, e.g.UpdateCondition.Builder
updateBuilder()
List<?>
values()
static <T> AttributeCondition.Builder<T>
where(Attribute<T> attribute)
Creates aAttributeCondition.Builder
instance based on the given attribute.static ForeignKeyConditionBuilder
where(ForeignKey foreignKey)
Creates aForeignKeyConditionBuilder
instance based on the given foreign key attribute.
-
-
-
Method Detail
-
entityType
EntityType entityType()
- Returns:
- the entity type
-
values
List<?> values()
- Returns:
- a list of the values this condition is based on, in the order they appear in the condition clause. An empty list is returned in case no values are specified.
-
attributes
List<Attribute<?>> attributes()
- Returns:
- a list of the attributes this condition is based on, in the same order as their respective values appear in the condition clause. An empty list is returned in case no values are specified.
-
and
Condition.Combination and(Condition... conditions)
Returns a new Combination instance, combining this condition with the given one, AND'ing together.- Parameters:
conditions
- the conditions to combine with this one- Returns:
- a new condition combination
-
or
Condition.Combination or(Condition... conditions)
Returns a new Combination instance, combining this condition with the given one, OR'ing together.- Parameters:
conditions
- the conditions to combine with this one- Returns:
- a new condition combination
-
toString
String toString(EntityDefinition definition)
Returns a string representing this condition, e.g. "column = ?" or "col1 is not null and col2 in (?, ?)".- Parameters:
definition
- the entity definition- Returns:
- a condition string
-
selectBuilder
SelectCondition.Builder selectBuilder()
- Returns:
- a
SelectCondition.Builder
instance based on this condition
-
updateBuilder
UpdateCondition.Builder updateBuilder()
- Returns:
- a
UpdateCondition.Builder
instance based on this condition
-
condition
static Condition condition(EntityType entityType)
Creates aCondition
instance specifying all entities of the type identified byentityType
- Parameters:
entityType
- the entityType- Returns:
- a condition specifying all entities of the given type
-
condition
static Condition condition(Key key)
Creates aCondition
based on the given key- Parameters:
key
- the key- Returns:
- a condition based on the given key
-
condition
static Condition condition(Collection<Key> keys)
Creates aCondition
based on the given keys, assuming they are all based on the same attributes.- Parameters:
keys
- the keys- Returns:
- a condition based on the given keys
- Throws:
IllegalArgumentException
- in casekeys
is empty
-
where
static ForeignKeyConditionBuilder where(ForeignKey foreignKey)
Creates aForeignKeyConditionBuilder
instance based on the given foreign key attribute.- Parameters:
foreignKey
- the foreign key to base the condition on- Returns:
- a
ForeignKeyConditionBuilder
instance
-
where
static <T> AttributeCondition.Builder<T> where(Attribute<T> attribute)
Creates aAttributeCondition.Builder
instance based on the given attribute.- Type Parameters:
T
- the attribute type- Parameters:
attribute
- the attribute to base the condition on- Returns:
- a
AttributeCondition.Builder
instance - Throws:
IllegalArgumentException
- in caseattribute
is aForeignKey
.- See Also:
where(ForeignKey)
-
combination
static Condition.Combination combination(Conjunction conjunction, Condition... conditions)
Initializes a newCondition.Combination
instance- Parameters:
conjunction
- the Conjunction to useconditions
- the conditions to combine- Returns:
- a new
Condition.Combination
instance
-
combination
static Condition.Combination combination(Conjunction conjunction, Collection<Condition> conditions)
Initializes a newCondition.Combination
instance- Parameters:
conjunction
- the Conjunction to useconditions
- the conditions to combine- Returns:
- a new
Condition.Combination
instance
-
customCondition
static CustomCondition customCondition(ConditionType conditionType)
Creates a newCustomCondition
based on the condition of the given type- Parameters:
conditionType
- the condition type- Returns:
- a new Condition instance
- Throws:
NullPointerException
- in case the condition type is null- See Also:
EntityDefinition.Builder.conditionProvider(ConditionType, ConditionProvider)
-
customCondition
static CustomCondition customCondition(ConditionType conditionType, List<Attribute<?>> attributes, List<Object> values)
Creates a newCustomCondition
based on the condition of the given type- Parameters:
conditionType
- the condition typeattributes
- the attributes representing the values used by this condition, in the same order as their respective valuesvalues
- the values used by this condition string- Returns:
- a new Condition instance
- Throws:
NullPointerException
- in case any of the parameters are null- See Also:
EntityDefinition.Builder.conditionProvider(ConditionType, ConditionProvider)
-
-