Class DefaultModelCriteria<M>
- java.lang.Object
-
- org.keycloak.models.map.storage.criteria.DefaultModelCriteria<M>
-
- All Implemented Interfaces:
ModelCriteriaBuilder<M,DefaultModelCriteria<M>>
public class DefaultModelCriteria<M> extends Object implements ModelCriteriaBuilder<M,DefaultModelCriteria<M>>
Descriptive model criteria implementation which in other words represents a Boolean formula on searchable fields.- Author:
- hmlnarik
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DefaultModelCriteria.AtomicFormulaTester<M>
-
Nested classes/interfaces inherited from interface org.keycloak.models.map.storage.ModelCriteriaBuilder
ModelCriteriaBuilder.Operator
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultModelCriteria<M>
and(DefaultModelCriteria<M>... mcbs)
Creates and returns a new instance ofModelCriteriaBuilder
that combines the given builders with the Boolean AND operator.DefaultModelCriteria<M>
compare(SearchableModelField<? super M> modelField, ModelCriteriaBuilder.Operator op, Object... value)
Adds a constraint for the given model field to this criteria builder and returns a criteria builder that is combined with the the new constraint.static <M> DefaultModelCriteria<M>
criteria()
<C extends ModelCriteriaBuilder<M,C>>
CflashToModelCriteriaBuilder(C mcb)
Copies contents of thisModelCriteriaBuilder
into anotherModelCriteriaBuilder
.boolean
isEmpty()
DefaultModelCriteria<M>
not(DefaultModelCriteria<M> mcb)
Creates and returns a new instance ofModelCriteriaBuilder
that negates the given builder.DefaultModelCriteria<M>
optimize()
Optimizes this formula into anotherModelCriteriaBuilder
, using the values ofModelCriteriaNode.ExtOperator.__TRUE__
andModelCriteriaNode.ExtOperator.__FALSE__
accordingly.DefaultModelCriteria<M>
or(DefaultModelCriteria<M>... mcbs)
Creates and returns a new instance ofModelCriteriaBuilder
that combines the given builders with the Boolean OR operator.DefaultModelCriteria<M>
partiallyEvaluate(DefaultModelCriteria.AtomicFormulaTester<M> tester)
String
toString()
-
-
-
Method Detail
-
criteria
public static <M> DefaultModelCriteria<M> criteria()
-
compare
public DefaultModelCriteria<M> compare(SearchableModelField<? super M> modelField, ModelCriteriaBuilder.Operator op, Object... value)
Description copied from interface:ModelCriteriaBuilder
Adds a constraint for the given model field to this criteria builder and returns a criteria builder that is combined with the the new constraint. The resulting constraint is a logical conjunction (i.e. AND) of the original constraint present in thisModelCriteriaBuilder
and the given operator.- Specified by:
compare
in interfaceModelCriteriaBuilder<M,DefaultModelCriteria<M>>
- Parameters:
modelField
- Field on the logical model to be constrainedop
- Operatorvalue
- Additional operands of the operator.- Returns:
-
and
public DefaultModelCriteria<M> and(DefaultModelCriteria<M>... mcbs)
Description copied from interface:ModelCriteriaBuilder
Creates and returns a new instance ofModelCriteriaBuilder
that combines the given builders with the Boolean AND operator.Predicate coming out of
and
on an empty array ofbuilders
(i.e. empty conjunction) is alwaystrue
.cb = storage.getCriteriaBuilder(); storage.read(cb.or( cb.and(cb.compare(FIELD1, EQ, 1), cb.compare(FIELD2, EQ, 2)), cb.and(cb.compare(FIELD1, EQ, 3), cb.compare(FIELD2, EQ, 4)) );
- Specified by:
and
in interfaceModelCriteriaBuilder<M,DefaultModelCriteria<M>>
-
or
public DefaultModelCriteria<M> or(DefaultModelCriteria<M>... mcbs)
Description copied from interface:ModelCriteriaBuilder
Creates and returns a new instance ofModelCriteriaBuilder
that combines the given builders with the Boolean OR operator.Predicate coming out of
or
on an empty array ofbuilders
(i.e. empty disjunction) is alwaysfalse
.cb = storage.getCriteriaBuilder(); storage.read(cb.or( cb.compare(FIELD1, EQ, 1).compare(FIELD2, EQ, 2), cb.compare(FIELD1, EQ, 3).compare(FIELD2, EQ, 4) );
- Specified by:
or
in interfaceModelCriteriaBuilder<M,DefaultModelCriteria<M>>
-
not
public DefaultModelCriteria<M> not(DefaultModelCriteria<M> mcb)
Description copied from interface:ModelCriteriaBuilder
Creates and returns a new instance ofModelCriteriaBuilder
that negates the given builder.Note that if the
builder
has no condition yet, there is nothing to negate: empty negation is alwaystrue
.- Specified by:
not
in interfaceModelCriteriaBuilder<M,DefaultModelCriteria<M>>
- Returns:
-
flashToModelCriteriaBuilder
public <C extends ModelCriteriaBuilder<M,C>> C flashToModelCriteriaBuilder(C mcb)
Copies contents of thisModelCriteriaBuilder
into anotherModelCriteriaBuilder
.- Parameters:
mcb
-ModelCriteriaBuilder
to copy the contents onto- Returns:
- Updated
ModelCriteriaBuilder
-
optimize
public DefaultModelCriteria<M> optimize()
Optimizes this formula into anotherModelCriteriaBuilder
, using the values ofModelCriteriaNode.ExtOperator.__TRUE__
andModelCriteriaNode.ExtOperator.__FALSE__
accordingly.- Returns:
- New instance of
-
partiallyEvaluate
public DefaultModelCriteria<M> partiallyEvaluate(DefaultModelCriteria.AtomicFormulaTester<M> tester)
-
isEmpty
public boolean isEmpty()
-
-