/** * Returns the given {@link Document} representing a keyword by mapping the keyword's value. * * @param keyword the {@link Document} representing a keyword (e.g. {@code $ne : … } ) * @param entity * @return */ protected Document getMappedKeyword(Keyword keyword, @Nullable MongoPersistentEntity<?> entity) { // $or/$nor if (keyword.isOrOrNor() || (keyword.hasIterableValue() && !keyword.isGeometry())) { Iterable<?> conditions = keyword.getValue(); List<Object> newConditions = new ArrayList<Object>(); for (Object condition : conditions) { newConditions.add(isDocument(condition) ? getMappedObject((Document) condition, entity) : convertSimpleOrDocument(condition, entity)); } return new Document(keyword.getKey(), newConditions); } if (keyword.isSample()) { return exampleMapper.getMappedExample(keyword.<Example<?>> getValue(), entity); } if (keyword.isJsonSchema()) { return schemaMapper.mapSchema(new Document(keyword.getKey(), keyword.getValue()), entity.getType()); } return new Document(keyword.getKey(), convertSimpleOrDocument(keyword.getValue(), entity)); }
/** * Returns the given {@link Document} representing a keyword by mapping the keyword's value. * * @param keyword the {@link Document} representing a keyword (e.g. {@code $ne : … } ) * @param entity * @return */ protected Document getMappedKeyword(Keyword keyword, @Nullable MongoPersistentEntity<?> entity) { // $or/$nor if (keyword.isOrOrNor() || (keyword.hasIterableValue() && !keyword.isGeometry())) { Iterable<?> conditions = keyword.getValue(); List<Object> newConditions = new ArrayList<Object>(); for (Object condition : conditions) { newConditions.add(isDocument(condition) ? getMappedObject((Document) condition, entity) : convertSimpleOrDocument(condition, entity)); } return new Document(keyword.getKey(), newConditions); } if (keyword.isSample()) { return exampleMapper.getMappedExample(keyword.<Example<?>> getValue(), entity); } if (keyword.isJsonSchema()) { return schemaMapper.mapSchema(new Document(keyword.getKey(), keyword.getValue()), entity.getType()); } return new Document(keyword.getKey(), convertSimpleOrDocument(keyword.getValue(), entity)); }