Package org.keycloak.models.map.storage
Interface ModelCriteriaBuilder<M,Self extends ModelCriteriaBuilder<M,Self>>
- 
- All Known Implementing Classes:
- DefaultModelCriteria,- DescriptiveModelCriteria,- FileCriteriaBuilder,- IckleQueryMapModelCriteriaBuilder,- JpaAdminEventModelCriteriaBuilder,- JpaAuthEventModelCriteriaBuilder,- JpaClientModelCriteriaBuilder,- JpaClientScopeModelCriteriaBuilder,- JpaGroupModelCriteriaBuilder,- JpaModelCriteriaBuilder,- JpaPermissionModelCriteriaBuilder,- JpaPolicyModelCriteriaBuilder,- JpaRealmModelCriteriaBuilder,- JpaResourceModelCriteriaBuilder,- JpaResourceServerModelCriteriaBuilder,- JpaRoleModelCriteriaBuilder,- JpaRootAuthenticationSessionModelCriteriaBuilder,- JpaScopeModelCriteriaBuilder,- JpaSingleUseObjectModelCriteriaBuilder,- JpaUserLoginFailureModelCriteriaBuilder,- JpaUserModelCriteriaBuilder,- JpaUserSessionModelCriteriaBuilder,- LdapModelCriteriaBuilder,- LdapRoleModelCriteriaBuilder,- MapModelCriteriaBuilder,- MapModelCriteriaBuilderAssumingEqualForField,- SingleUseObjectModelCriteriaBuilder
 
 public interface ModelCriteriaBuilder<M,Self extends ModelCriteriaBuilder<M,Self>>Builder for criteria that can be used to limit results obtained from the store. This class is used for similar purpose as e.g. JPA'sCriteriaBuilder, however it is much simpler version as it is tailored to very specific needs of future Keycloak store.Implementations are expected to be immutable. The expected use is like this: 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) ) );The above code should read items where(FIELD1 == 1 && FIELD2 == 2) || (FIELD1 == 3 && FIELD2 == 4).It is equivalent to this: 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)) ) );- Author:
- hmlnarik
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Interface Description static classModelCriteriaBuilder.OperatorThe operators are very basic ones for this use case.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description Selfand(Self... builders)Creates and returns a new instance ofModelCriteriaBuilderthat combines the given builders with the Boolean AND operator.Selfcompare(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.Selfnot(Self builder)Creates and returns a new instance ofModelCriteriaBuilderthat negates the given builder.Selfor(Self... builders)Creates and returns a new instance ofModelCriteriaBuilderthat combines the given builders with the Boolean OR operator.
 
- 
- 
- 
Method Detail- 
compareSelf 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. The resulting constraint is a logical conjunction (i.e. AND) of the original constraint present in thisModelCriteriaBuilderand the given operator.- Parameters:
- modelField- Field on the logical model to be constrained
- op- Operator
- value- Additional operands of the operator.
- Returns:
- Throws:
- CriterionNotSupportedException- If the operator is not supported for the given field.
 
 - 
andSelf and(Self... builders) Creates and returns a new instance ofModelCriteriaBuilderthat combines the given builders with the Boolean AND operator.Predicate coming out of andon 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)) );- Throws:
- CriterionNotSupportedException- If the operator is not supported for the given field.
 
 - 
orSelf or(Self... builders) Creates and returns a new instance ofModelCriteriaBuilderthat combines the given builders with the Boolean OR operator.Predicate coming out of oron 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) );- Throws:
- CriterionNotSupportedException- If the operator is not supported for the given field.
 
 - 
notSelf not(Self builder) Creates and returns a new instance ofModelCriteriaBuilderthat negates the given builder.Note that if the builderhas no condition yet, there is nothing to negate: empty negation is alwaystrue.- Parameters:
- builder-
- Returns:
- Throws:
- CriterionNotSupportedException- If the operator is not supported for the given field.
 
 
- 
 
-