DATAMONGO-1703 - Polishing.
Use lombok's Value for ObjectPathItem. Make methods accessible in DefaultDbRefResolver before calling. Use class.cast to avoid warnings. Update Javadoc. Original pull request: #478.
This commit is contained in:
@@ -326,6 +326,8 @@ public class DefaultDbRefResolver implements DbRefResolver {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReflectionUtils.makeAccessible(method);
|
||||||
|
|
||||||
return method.invoke(target, args);
|
return method.invoke(target, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core.convert;
|
package org.springframework.data.mongodb.core.convert;
|
||||||
|
|
||||||
|
import lombok.Value;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -29,8 +31,8 @@ import org.springframework.util.StringUtils;
|
|||||||
* when resolving more nested objects. This allows to avoid re-resolving object instances that are logically equivalent
|
* when resolving more nested objects. This allows to avoid re-resolving object instances that are logically equivalent
|
||||||
* to already resolved ones.
|
* to already resolved ones.
|
||||||
* <p>
|
* <p>
|
||||||
* An immutable ordered set of target objects for {@link Document} to {@link Object} conversions. Object paths can be
|
* An immutable ordered set of target objects for {@link org.bson.Document} to {@link Object} conversions. Object paths
|
||||||
* constructed by the {@link #toObjectPath(Object)} method and extended via {@link #push(Object)}.
|
* can be extended via {@link #push(Object, MongoPersistentEntity, Object)}.
|
||||||
*
|
*
|
||||||
* @author Thomas Darimont
|
* @author Thomas Darimont
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
@@ -138,7 +140,7 @@ class ObjectPath {
|
|||||||
|
|
||||||
if (collection.equals(item.getCollection()) && id.equals(item.getIdValue())
|
if (collection.equals(item.getCollection()) && id.equals(item.getIdValue())
|
||||||
&& ClassUtils.isAssignable(type, object.getClass())) {
|
&& ClassUtils.isAssignable(type, object.getClass())) {
|
||||||
return (T) object;
|
return type.cast(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,37 +181,13 @@ class ObjectPath {
|
|||||||
*
|
*
|
||||||
* @author Thomas Darimont
|
* @author Thomas Darimont
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
|
@Value
|
||||||
private static class ObjectPathItem {
|
private static class ObjectPathItem {
|
||||||
|
|
||||||
private final Object object;
|
Object object;
|
||||||
private final Object idValue;
|
Object idValue;
|
||||||
private final String collection;
|
String collection;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link ObjectPathItem}.
|
|
||||||
*
|
|
||||||
* @param object
|
|
||||||
* @param idValue
|
|
||||||
* @param collection
|
|
||||||
*/
|
|
||||||
ObjectPathItem(Object object, Object idValue, String collection) {
|
|
||||||
|
|
||||||
this.object = object;
|
|
||||||
this.idValue = idValue;
|
|
||||||
this.collection = collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object getObject() {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object getIdValue() {
|
|
||||||
return idValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getCollection() {
|
|
||||||
return collection;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user