@Nullable @Override public <T> T findAndModify(Query query, Update update, FindAndModifyOptions options, Class<T> entityClass, String collectionName) { Assert.notNull(query, "Query must not be null!"); Assert.notNull(update, "Update must not be null!"); Assert.notNull(options, "Options must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null!"); FindAndModifyOptions optionsToUse = FindAndModifyOptions.of(options); Optionals.ifAllPresent(query.getCollation(), optionsToUse.getCollation(), (l, r) -> { throw new IllegalArgumentException( "Both Query and FindAndModifyOptions define a collation. Please provide the collation only via one of the two."); }); query.getCollation().ifPresent(optionsToUse::collation); return doFindAndModify(collectionName, query.getQueryObject(), query.getFieldsObject(), getMappedSortObject(query, entityClass), entityClass, update, optionsToUse); }
public <T> Mono<T> findAndModify(Query query, Update update, FindAndModifyOptions options, Class<T> entityClass, String collectionName) { FindAndModifyOptions optionsToUse = FindAndModifyOptions.of(options); Optionals.ifAllPresent(query.getCollation(), optionsToUse.getCollation(), (l, r) -> { throw new IllegalArgumentException( "Both Query and FindAndModifyOptions define a collation. Please provide the collation only via one of the two."); }); query.getCollation().ifPresent(optionsToUse::collation); return doFindAndModify(collectionName, query.getQueryObject(), query.getFieldsObject(), getMappedSortObject(query, entityClass), entityClass, update, optionsToUse); }
Optionals.ifAllPresent(filterQuery.getCollation(), options.getCollation(), (l, r) -> { throw new IllegalArgumentException( "Both Query and MapReduceOptions define a collation. Please provide the collation only via one of the two.");
Optionals.ifAllPresent(collation, mapReduceOptions.getCollation(), (l, r) -> { throw new IllegalArgumentException( "Both Query and MapReduceOptions define a collation. Please provide the collation only via one of the two.");
private List<BeanPropertyDefinition> getMappedProperties(PersistentEntity<?, ?> entity) { List<BeanPropertyDefinition> properties = getBeanDescription(entity.getType()).findProperties(); List<BeanPropertyDefinition> withInternalName = new ArrayList<BeanPropertyDefinition>(properties.size()); for (BeanPropertyDefinition property : properties) { Optionals.ifAllPresent(findAnnotatedMember(property), // Optional.ofNullable(entity.getPersistentProperty(property.getInternalName())), // (member, prop) -> withInternalName.add(property)); } return withInternalName; }
@Nullable @Override public <T> T findAndModify(Query query, Update update, FindAndModifyOptions options, Class<T> entityClass, String collectionName) { Assert.notNull(query, "Query must not be null!"); Assert.notNull(update, "Update must not be null!"); Assert.notNull(options, "Options must not be null!"); Assert.notNull(entityClass, "EntityClass must not be null!"); Assert.notNull(collectionName, "CollectionName must not be null!"); FindAndModifyOptions optionsToUse = FindAndModifyOptions.of(options); Optionals.ifAllPresent(query.getCollation(), optionsToUse.getCollation(), (l, r) -> { throw new IllegalArgumentException( "Both Query and FindAndModifyOptions define a collation. Please provide the collation only via one of the two."); }); query.getCollation().ifPresent(optionsToUse::collation); return doFindAndModify(collectionName, query.getQueryObject(), query.getFieldsObject(), getMappedSortObject(query, entityClass), entityClass, update, optionsToUse); }
private Map<String, List<PersistentProperty<?>>> findUnwrappedPropertyPaths(Class<?> type, NameTransformer nameTransformer, boolean considerRegularProperties) { return persistentEntities.getPersistentEntity(type).map(entity -> { Map<String, List<PersistentProperty<?>>> mapping = new HashMap<String, List<PersistentProperty<?>>>(); for (BeanPropertyDefinition property : getMappedProperties(entity)) { Optionals.ifAllPresent(Optional.ofNullable(entity.getPersistentProperty(property.getInternalName())), // findAnnotatedMember(property), // (prop, member) -> { if (isJsonUnwrapped(member)) { mapping.putAll(findUnwrappedPropertyPaths(nameTransformer, member, prop)); } else if (considerRegularProperties) { mapping.put(nameTransformer.transform(property.getName()), Collections.<PersistentProperty<?>> singletonList(prop)); } }); } return mapping; }).orElse(Collections.emptyMap()); }
public <T> Mono<T> findAndModify(Query query, Update update, FindAndModifyOptions options, Class<T> entityClass, String collectionName) { FindAndModifyOptions optionsToUse = FindAndModifyOptions.of(options); Optionals.ifAllPresent(query.getCollation(), optionsToUse.getCollation(), (l, r) -> { throw new IllegalArgumentException( "Both Query and FindAndModifyOptions define a collation. Please provide the collation only via one of the two."); }); query.getCollation().ifPresent(optionsToUse::collation); return doFindAndModify(collectionName, query.getQueryObject(), query.getFieldsObject(), getMappedSortObject(query, entityClass), entityClass, update, optionsToUse); }
Optionals.ifAllPresent(filterQuery.getCollation(), options.getCollation(), (l, r) -> { throw new IllegalArgumentException( "Both Query and MapReduceOptions define a collation. Please provide the collation only via one of the two.");
Optionals.ifAllPresent(collation, mapReduceOptions.getCollation(), (l, r) -> { throw new IllegalArgumentException( "Both Query and MapReduceOptions define a collation. Please provide the collation only via one of the two.");
private List<BeanPropertyDefinition> getMappedProperties(PersistentEntity<?, ?> entity) { List<BeanPropertyDefinition> properties = getBeanDescription(entity.getType()).findProperties(); List<BeanPropertyDefinition> withInternalName = new ArrayList<BeanPropertyDefinition>(properties.size()); for (BeanPropertyDefinition property : properties) { Optionals.ifAllPresent(findAnnotatedMember(property), // Optional.ofNullable(entity.getPersistentProperty(property.getInternalName())), // (member, prop) -> withInternalName.add(property)); } return withInternalName; }
private Map<String, List<PersistentProperty<?>>> findUnwrappedPropertyPaths(Class<?> type, NameTransformer nameTransformer, boolean considerRegularProperties) { return persistentEntities.getPersistentEntity(type).map(entity -> { Map<String, List<PersistentProperty<?>>> mapping = new HashMap<String, List<PersistentProperty<?>>>(); for (BeanPropertyDefinition property : getMappedProperties(entity)) { Optionals.ifAllPresent(Optional.ofNullable(entity.getPersistentProperty(property.getInternalName())), // findAnnotatedMember(property), // (prop, member) -> { if (isJsonUnwrapped(member)) { mapping.putAll(findUnwrappedPropertyPaths(nameTransformer, member, prop)); } else if (considerRegularProperties) { mapping.put(nameTransformer.transform(property.getName()), Collections.<PersistentProperty<?>> singletonList(prop)); } }); } return mapping; }).orElse(Collections.emptyMap()); }