BeanIO 2.0.4

org.beanio.internal.util
Class Replicator

java.lang.Object
  extended by org.beanio.internal.util.Replicator

public class Replicator
extends Object

Utility class used to copy a hierarchical object graph.

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.

Since:
2.0
Author:
Kevin Seim

Constructor Summary
Replicator()
          Constructs a new Replicator.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Replicator

public Replicator()
Constructs a new Replicator.

Method Detail

register

public void register(Replicateable node)
Registers a node in a graph that can be copied.

Parameters:
node - the graph node to register

replicate

public <T> T replicate(T value)
Returns a copy of the registered graph node and its descendants. This method will clone all registered nodes allow each node to update its references.

Type Parameters:
T - the node type
Parameters:
value - the root graph node
Returns:
a copy of the root graph node and its descendants
Throws:
IllegalStateException - if value is not a registered node

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim