Source:
public static String generateSvgPrimitive(final String instanceId, final Function<PrimitiveDefinition, PrimitiveDefinitionGenerator<PrimitiveDefinition<?>>> generatorProvider, final PrimitiveDefinition child) { String childRaw = null; try { final StringBuffer childBuffer = generatorProvider.apply(child).generate(child); final boolean scalable = child.isScalable(); final String scalableRaw = scalable ? "true" : "false"; final LayoutDefinition layoutDefinition = child.getLayoutDefinition(); final String childLayoutRaw = formatLayout(layoutDefinition); if (child instanceof ShapeDefinition) { final String policyRaw = formatShapePolicy(((ShapeDefinition) child).getShapePolicyDefinition()); childRaw = AbstractGenerator.formatString(NEW_SVG_SHAPE_TEMPLATE, instanceId, childBuffer.toString(), scalableRaw, childLayoutRaw, policyRaw); } else if (child instanceof GroupDefinition) { final GroupDefinition groupDefinition = (GroupDefinition) child; childRaw = AbstractGenerator.formatString(NEW_SVG_CONTAINER_TEMPLATE, instanceId, groupDefinition.getId(), childBuffer.toString(), scalableRaw, childLayoutRaw); final List<PrimitiveDefinition> children = groupDefinition.getChildren(); for (int j = 0; j < children.size(); j++) { final PrimitiveDefinition childDef = children.get(j); final String childDefInstanceId = instanceId + "_" + j; final String childDefRaw = generateSvgPrimitive(childDefInstanceId, generatorProvider, childDef); if (null != childDefRaw) { childRaw += childDefRaw; childRaw += AbstractGenerator.formatString(GROUP_ADD_CHILD_TEMPLATE, instanceId, childDefInstanceId); } } } } catch (GeneratorException e) { throw new RuntimeException(e); } return childRaw; }

Target:
public static String generateSvgPrimitive(final String instanceId, final Function<PrimitiveDefinition, PrimitiveDefinitionGenerator<PrimitiveDefinition<?>>> generatorProvider, final PrimitiveDefinition child) { String childRaw = null; try { final StringBuffer childBuffer = generatorProvider.apply(child).generate(child); final String scalableRaw = String.valueOf(child.isScalable()); final LayoutDefinition layoutDefinition = child.getLayoutDefinition(); final String childLayoutRaw = formatLayout(layoutDefinition); if (child instanceof ShapeDefinition) { final String policyRaw = formatShapePolicy(((ShapeDefinition) child).getShapePolicyDefinition()); childRaw = AbstractGenerator.formatString(NEW_SVG_SHAPE_TEMPLATE, instanceId, childBuffer.toString(), scalableRaw, childLayoutRaw, policyRaw); } else if (child instanceof GroupDefinition) { final GroupDefinition groupDefinition = (GroupDefinition) child; childRaw = AbstractGenerator.formatString(NEW_SVG_CONTAINER_TEMPLATE, instanceId, groupDefinition.getId(), childBuffer.toString(), scalableRaw, childLayoutRaw); final List<PrimitiveDefinition> children = groupDefinition.getChildren(); for (int j = 0; j < children.size(); j++) { final PrimitiveDefinition childDef = children.get(j); final String childDefInstanceId = instanceId + "_" + j; final String childDefRaw = generateSvgPrimitive(childDefInstanceId, generatorProvider, childDef); if (null != childDefRaw) { childRaw += childDefRaw; childRaw += AbstractGenerator.formatString(GROUP_ADD_CHILD_TEMPLATE, instanceId, childDefInstanceId); } } } } catch (GeneratorException e) { throw new RuntimeException(e); } return childRaw; }