public interface Duplicatable
Cloneable
interface without its side-effects. A class implementing Duplicatable provides a deep-copy of itself - usually this is done via a copy-constructor, which is invoked with a self-reference by the copy method. References to child objects are duplicated - references to parents are kept as-is and might need to be replaced by the parent copy operation.
(这是 Cloneable 接口的替代方案,没有副作用。实现 Duplicatable 的类提供了自身的深拷贝——通常这是通过拷贝构造函数完成的,拷贝构造函数通过拷贝方法的自引用调用。对子对象的引用是重复的 - 对父对象的引用保持原样,可能需要由父复制操作替换。)
Modifier and Type | Method and Description |
---|---|
Duplicatable |
copy() |
Duplicatable copy()
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.