Search in sources :

Example 1 with KeyExtractor

use of org.immutables.criteria.backend.KeyExtractor in project immutables by immutables.

the class KeyLookupAnalyzerTest method ids.

private static Iterable<String> ids(StringHolderCriteria crit) {
    Expression filter = Criterias.toQuery(crit).filter().orElseThrow(() -> new AssertionError("No filter present"));
    KeyExtractor extractor = KeyExtractor.defaultFactory().create(TypeHolder.StringHolder.class);
    KeyLookupAnalyzer analyzer = KeyLookupAnalyzer.fromExtractor(extractor);
    KeyLookupAnalyzer.Result result = analyzer.analyze(filter);
    if (!result.isOptimizable()) {
        return Collections.emptyList();
    }
    return (Iterable<String>) result.values();
}
Also used : TypeHolder(org.immutables.criteria.typemodel.TypeHolder) Expression(org.immutables.criteria.expression.Expression) KeyExtractor(org.immutables.criteria.backend.KeyExtractor)

Example 2 with KeyExtractor

use of org.immutables.criteria.backend.KeyExtractor in project immutables by immutables.

the class MongoBackend method open.

@Override
public Session open(Class<?> entityType) {
    Objects.requireNonNull(entityType, "context");
    KeyExtractor keyExtractor = keyExtractorFactory.create(entityType);
    return new MongoSession(collectionResolver.resolve(entityType), keyExtractor);
}
Also used : KeyExtractor(org.immutables.criteria.backend.KeyExtractor)

Aggregations

KeyExtractor (org.immutables.criteria.backend.KeyExtractor)2 Expression (org.immutables.criteria.expression.Expression)1 TypeHolder (org.immutables.criteria.typemodel.TypeHolder)1