public interface InstanceFactory
DiffNode.canonicalSet(Object,
Object)
is called on a node for which the target returns null
for its parent. The parent (and
subsequently all of its predecessors along the path) will be created via this factory and inserted into the target
object.限定符和类型 | 方法和说明 |
---|---|
java.lang.Object |
newInstanceOfType(java.lang.Class<?> type) |
java.lang.Object newInstanceOfType(java.lang.Class<?> type)
type
- The type for which a new instance should be createdtype
or null
if it doesn't know how to instantiate
the type. In case of the latter, the ObjectDiffer
will automatically fallback to
instantiation via public non-arg constructor. If that also fails, an TypeInstantiationException
will be thrown.
Note from the author: it wasn't an easy decision, but in the end I favored an exception over
logging a warning, because this way it is much harder to accidentally end up with incomplete merges without
noticing. If this turns out to be a problem for you, please let me know in the issue tracker. We could probably
add a flag to switch to the logging-only mode. But as long as nobody complains, I'll just leave it as it is right
now.