Class MapModelCriteriaBuilder<K,V extends AbstractEntity,M>
- java.lang.Object
-
- org.keycloak.models.map.storage.chm.MapModelCriteriaBuilder<K,V,M>
-
- All Implemented Interfaces:
ModelCriteriaBuilder<M,MapModelCriteriaBuilder<K,V,M>>
- Direct Known Subclasses:
MapModelCriteriaBuilderAssumingEqualForField
public class MapModelCriteriaBuilder<K,V extends AbstractEntity,M> extends Object implements ModelCriteriaBuilder<M,MapModelCriteriaBuilder<K,V,M>>
- Author:
- hmlnarik
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V extends AbstractEntity,M>
-
Nested classes/interfaces inherited from interface org.keycloak.models.map.storage.ModelCriteriaBuilder
ModelCriteriaBuilder.Operator
-
-
Field Summary
Fields Modifier and Type Field Description protected static Predicate<Object>
ALWAYS_FALSE
protected static Predicate<Object>
ALWAYS_TRUE
-
Constructor Summary
Constructors Modifier Constructor Description MapModelCriteriaBuilder(StringKeyConverter<K> keyConverter, Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>> fieldPredicates)
protected
MapModelCriteriaBuilder(StringKeyConverter<K> keyConverter, Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>> fieldPredicates, Predicate<? super K> indexReadFilter, Predicate<? super V> sequentialReadFilter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MapModelCriteriaBuilder<K,V,M>
and(MapModelCriteriaBuilder<K,V,M>... builders)
Creates and returns a new instance ofModelCriteriaBuilder
that combines the given builders with the Boolean AND operator.MapModelCriteriaBuilder<K,V,M>
compare(SearchableModelField<? super M> modelField, ModelCriteriaBuilder.Operator op, Object... values)
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.protected Object[]
convertValuesToKeyType(Object[] values)
protected MapModelCriteriaBuilder<K,V,M>
fieldCompare(Predicate<Object> valueComparator, Function<V,?> getter)
protected MapModelCriteriaBuilder<K,V,M>
fieldCompare(ModelCriteriaBuilder.Operator op, Function<V,?> getter, Object[] values)
Predicate<? super V>
getEntityFilter()
Predicate<? super K>
getKeyFilter()
protected MapModelCriteriaBuilder<K,V,M>
idCompare(ModelCriteriaBuilder.Operator op, Object[] values)
protected MapModelCriteriaBuilder<K,V,M>
instantiateNewInstance(StringKeyConverter<K> keyConverter, Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>> fieldPredicates, Predicate<? super K> indexReadFilter, Predicate<? super V> sequentialReadFilter)
Return a new instance for nodes in this criteria tree.MapModelCriteriaBuilder<K,V,M>
not(MapModelCriteriaBuilder<K,V,M> builder)
Creates and returns a new instance ofModelCriteriaBuilder
that negates the given builder.MapModelCriteriaBuilder<K,V,M>
or(MapModelCriteriaBuilder<K,V,M>... builders)
Creates and returns a new instance ofModelCriteriaBuilder
that combines the given builders with the Boolean OR operator.
-
-
-
Constructor Detail
-
MapModelCriteriaBuilder
public MapModelCriteriaBuilder(StringKeyConverter<K> keyConverter, Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>> fieldPredicates)
-
MapModelCriteriaBuilder
protected MapModelCriteriaBuilder(StringKeyConverter<K> keyConverter, Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>> fieldPredicates, Predicate<? super K> indexReadFilter, Predicate<? super V> sequentialReadFilter)
-
-
Method Detail
-
compare
public MapModelCriteriaBuilder<K,V,M> compare(SearchableModelField<? super M> modelField, ModelCriteriaBuilder.Operator op, Object... values)
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<K,V extends AbstractEntity>
- Parameters:
modelField
- Field on the logical model to be constrainedop
- Operatorvalues
- Additional operands of the operator.- Returns:
-
and
@SafeVarargs public final MapModelCriteriaBuilder<K,V,M> and(MapModelCriteriaBuilder<K,V,M>... builders)
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<K,V extends AbstractEntity>
-
or
@SafeVarargs public final MapModelCriteriaBuilder<K,V,M> or(MapModelCriteriaBuilder<K,V,M>... builders)
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<K,V extends AbstractEntity>
-
not
public MapModelCriteriaBuilder<K,V,M> not(MapModelCriteriaBuilder<K,V,M> builder)
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<K,V extends AbstractEntity>
- Returns:
-
idCompare
protected MapModelCriteriaBuilder<K,V,M> idCompare(ModelCriteriaBuilder.Operator op, Object[] values)
-
fieldCompare
protected MapModelCriteriaBuilder<K,V,M> fieldCompare(ModelCriteriaBuilder.Operator op, Function<V,?> getter, Object[] values)
-
fieldCompare
protected MapModelCriteriaBuilder<K,V,M> fieldCompare(Predicate<Object> valueComparator, Function<V,?> getter)
-
instantiateNewInstance
protected MapModelCriteriaBuilder<K,V,M> instantiateNewInstance(StringKeyConverter<K> keyConverter, Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>> fieldPredicates, Predicate<? super K> indexReadFilter, Predicate<? super V> sequentialReadFilter)
Return a new instance for nodes in this criteria tree. Subclasses can override this method to instantiate a new instance of their subclass. This allows this class to be extendable.
-
-