/** * Returns the value the given {@link MongoPersistentProperty} refers to. By default this will be a direct field but * the method will also transparently resolve nested values the {@link MongoPersistentProperty} might refer to through * a path expression in the field name metadata. * * @param property must not be {@literal null}. * @return */ @Nullable public Object get(MongoPersistentProperty property) { String fieldName = property.getFieldName(); Map<String, Object> map = BsonUtils.asMap(document); if (!fieldName.contains(".")) { return map.get(fieldName); } Iterator<String> parts = Arrays.asList(fieldName.split("\\.")).iterator(); Map<String, Object> source = map; Object result = null; while (source != null && parts.hasNext()) { result = source.get(parts.next()); if (parts.hasNext()) { source = getAsMap(result); } } return result; }
source = getAsMap(result);
/** * Returns the value the given {@link MongoPersistentProperty} refers to. By default this will be a direct field but * the method will also transparently resolve nested values the {@link MongoPersistentProperty} might refer to through * a path expression in the field name metadata. * * @param property must not be {@literal null}. * @return */ @Nullable public Object get(MongoPersistentProperty property) { String fieldName = property.getFieldName(); Map<String, Object> map = BsonUtils.asMap(document); if (!fieldName.contains(".")) { return map.get(fieldName); } Iterator<String> parts = Arrays.asList(fieldName.split("\\.")).iterator(); Map<String, Object> source = map; Object result = null; while (source != null && parts.hasNext()) { result = source.get(parts.next()); if (parts.hasNext()) { source = getAsMap(result); } } return result; }
source = getAsMap(result);