package pl.dzielins42.dmtools.generator.name;

import pl.dzielins42.dmtools.generator.GeneratorOptions;

public class PatternNameGenerator implements NameGenerator {

    private int[][] patterns;
    private String[][] arrays;

    public PatternNameGenerator(int[][] patterns, String[]... arrays) {
        super();
        this.patterns = patterns;
        this.arrays = arrays;
        // TODO validate
    }

    @Override
    public String generate(GeneratorOptions options) {
        // Get random pattern
        int[] pattern = patterns[options.nextInt(patterns.length)];

        StringBuilder sb = new StringBuilder();
        // Iterate over pattern
        for (int i = 0; i < pattern.length; i++) {
            sb.append(arrays[pattern[i]][options.nextInt(arrays[pattern[i]].length)]);
        }

        return sb.toString();
    }

}

@@ -158,16 +158,61 @@
 erator %7B
+%0A    %0A    public static final int SPACE = -1;
 %0A%0A    pr
@@ -747,24 +747,120 @@
 gth; i++) %7B%0A
+            if (pattern%5Bi%5D == SPACE) %7B%0A                sb.append(%22 %22);%0A            %7D else %7B%0A    
             
@@ -934,16 +934,30 @@
 gth)%5D);%0A
+            %7D%0A
         

Add simple way to insert space between random strings in PatternNameGenerator. Without this, a single item array would be needed to add space between words.