List of usage examples for com.mongodb.client FindIterable collation
FindIterable<TResult> collation(@Nullable Collation collation);
A null value represents the server default.
From source file:org.springframework.data.mongodb.core.messaging.TailableCursorTask.java
License:Apache License
@Override protected MongoCursor<Document> initCursor(MongoTemplate template, RequestOptions options, Class<?> targetType) { Document filter = new Document(); Collation collation = null;//from w w w . ja v a 2s. co m if (options instanceof TailableCursorRequest.TailableCursorRequestOptions) { TailableCursorRequestOptions requestOptions = (TailableCursorRequestOptions) options; if (requestOptions.getQuery().isPresent()) { Query query = requestOptions.getQuery().get(); filter.putAll(queryMapper.getMappedObject(query.getQueryObject(), template.getConverter().getMappingContext().getPersistentEntity( targetType.equals(Document.class) ? Object.class : targetType))); collation = query.getCollation() .map(org.springframework.data.mongodb.core.query.Collation::toMongoCollation).orElse(null); } } FindIterable<Document> iterable = template.getCollection(options.getCollectionName()).find(filter) .cursorType(CursorType.TailableAwait).noCursorTimeout(true); if (collation != null) { iterable = iterable.collation(collation); } return iterable.iterator(); }