out.append(statement(destRef.newDestination.declareIterator()));
}
List<Node> children = new ArrayList<Node>();
children.add(destRef);
while (!children.isEmpty()) {
Node child = children.remove(0);
children.addAll(child.children);
if (child.elementRef != null) {
out.append(statement(child.elementRef.declare()));
if (child.multiOccurrenceVar.isArray()) {
out.append(statement(child.multiOccurrenceVar.declareIterator()));
}
if (child.elementRef.isPrimitive()) {
out.append(statement(child.nullCheckFlag.declare("true")));
}
out.append(statement(child.shouldAddToCollectorFlag.declare("false")));
}
}
}
}
// TODO: need to create a flag variable to mark whether destination has been added
// to it's collector; it should be set to false upon new destination element creation
// MapperFactory mapperFactory = (MapperFactory) code.getMappingContext().getProperty(Properties.MAPPER_FACTORY);
StringBuilder endWhiles = new StringBuilder();
StringBuilder addLastElement = new StringBuilder();
iterateSources(sourceNodes, destNodes, out, endWhiles);
LinkedList<Node> stack = new LinkedList<Node>(destNodes);
while (!stack.isEmpty()) {
Node currentNode = stack.removeFirst();
stack.addAll(0, currentNode.children);
Node srcNode = null;
if (currentNode.value != null) {
srcNode = Node.findFieldMap(currentNode.value, sourceNodes, true);
} else {
FieldMap fieldMap = currentNode.getMap();
if (fieldMap != null) {