package net.divlight.retainer;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ObjectClassNameBuilder {
    private static final String RETAINER_CLASS_SUFFIX = "_Retainer";

    private final String targetClassSimpleName;
    private final List<String> enclosingClassSimpleNames = new ArrayList<>();

    public ObjectClassNameBuilder(String targetClassSimpleName) {
        this.targetClassSimpleName = targetClassSimpleName;
    }

    public ObjectClassNameBuilder addEnclosingClassSimpleName(String enclosingClassSimpleName) {
        enclosingClassSimpleNames.add(enclosingClassSimpleName);
        return this;
    }

    public String build() {
        String name = "";
        Collections.reverse(enclosingClassSimpleNames);
        for (String enclosingClassSimpleName : enclosingClassSimpleNames) {
            name += enclosingClassSimpleName + "$";
        }
        return name + targetClassSimpleName + RETAINER_CLASS_SUFFIX;
    }
}

@@ -705,24 +705,61 @@
     
-String name = %22%22
+final StringBuilder nameBuilder = new StringBuilder()
 ;%0A  
@@ -908,12 +908,23 @@
 name
- += 
+Builder.append(
 encl
@@ -947,14 +947,21 @@
 Name
- + 
+).append(
 %22$%22
+)
 ;%0A  
@@ -987,16 +987,23 @@
 urn name
+Builder
  + targe

Use StringBuilder in ObjectClassNameBuilder