public class Replicator extends Object
If all nodes in the graph implement Replicateable
and are registered
using register(Replicateable)
, calling replicate(Object)
and passing the root node in the graph will clone all registered nodes and
return a copy of the root node with references to copies of its descendents.
Constructor and Description |
---|
Replicator()
Constructs a new Replicator.
|
Modifier and Type | Method and Description |
---|---|
void |
register(Replicateable node)
Registers a node in a graph that can be copied.
|
<T> T |
replicate(T value)
Returns a copy of the registered graph node and its descendants.
|
public void register(Replicateable node)
node
- the graph node to registerpublic <T> T replicate(T value)
T
- the node typevalue
- the root graph nodeIllegalStateException
- if value is not a registered node