json/src/main/java/org/netbeans/html/json/impl/ModelProcessor.java
changeset 1011 267ca1bfeb6f
parent 990 581f50820e5e
child 1014 c89b9f91ed18
     1.1 --- a/json/src/main/java/org/netbeans/html/json/impl/ModelProcessor.java	Sat Sep 19 15:05:59 2015 +0200
     1.2 +++ b/json/src/main/java/org/netbeans/html/json/impl/ModelProcessor.java	Wed Oct 28 19:29:17 2015 +0100
     1.3 @@ -270,9 +270,11 @@
     1.4                  }
     1.5                  w.append("  };\n");
     1.6                  if (props.length > 0) {
     1.7 -                    w.append("  public ").append(className).append("(");
     1.8 +                    StringBuilder constructorWithArguments = new StringBuilder();
     1.9 +                    constructorWithArguments.append("  public ").append(className).append("(");
    1.10                      Prprt firstArray = null;
    1.11                      String sep = "";
    1.12 +                    int parameterCount = 0;
    1.13                      for (Prprt p : props) {
    1.14                          if (p.array()) {
    1.15                              if (firstArray == null) {
    1.16 @@ -281,11 +283,12 @@
    1.17                              continue;
    1.18                          }
    1.19                          String tn = typeName(p);
    1.20 -                        w.write(sep);
    1.21 -                        w.write(tn);
    1.22 +                        constructorWithArguments.append(sep);
    1.23 +                        constructorWithArguments.append(tn);
    1.24                          String[] third = toGetSet(p.name(), tn, false);
    1.25 -                        w.write(" " + third[2]);
    1.26 +                        constructorWithArguments.append(" ").append(third[2]);
    1.27                          sep = ", ";
    1.28 +                        parameterCount++;
    1.29                      }
    1.30                      if (firstArray != null) {
    1.31                          String tn;
    1.32 @@ -293,25 +296,29 @@
    1.33                          boolean[] isEnum = {false};
    1.34                          boolean isPrimitive[] = {false};
    1.35                          tn = checkType(firstArray, isModel, isEnum, isPrimitive);
    1.36 -                        w.write(sep);
    1.37 -                        w.write(tn);
    1.38 +                        constructorWithArguments.append(sep);
    1.39 +                        constructorWithArguments.append(tn);
    1.40                          String[] third = toGetSet(firstArray.name(), tn, true);
    1.41 -                        w.write("... " + third[2]);
    1.42 +                        constructorWithArguments.append("... ").append(third[2]);
    1.43 +                        parameterCount++;
    1.44                      }
    1.45 -                    w.append(") {\n");
    1.46 -                    w.append("    this(net.java.html.BrwsrCtx.findDefault(").append(className).append(".class));\n");
    1.47 +                    constructorWithArguments.append(") {\n");
    1.48 +                    constructorWithArguments.append("    this(net.java.html.BrwsrCtx.findDefault(").append(className).append(".class));\n");
    1.49                      for (Prprt p : props) {
    1.50                          if (p.array()) {
    1.51                              continue;
    1.52                          }
    1.53                          String[] third = toGetSet(p.name(), null, false);
    1.54 -                        w.write("    this.prop_" + p.name() + " = " + third[2] + ";\n");
    1.55 +                        constructorWithArguments.append("    this.prop_" + p.name() + " = " + third[2] + ";\n");
    1.56                      }
    1.57                      if (firstArray != null) {
    1.58                          String[] third = toGetSet(firstArray.name(), null, true);
    1.59 -                        w.write("    proto.initTo(this.prop_" + firstArray.name() + ", " + third[2] + ");\n");
    1.60 +                        constructorWithArguments.append("    proto.initTo(this.prop_" + firstArray.name() + ", " + third[2] + ");\n");
    1.61                      }
    1.62 -                    w.append("  };\n");
    1.63 +                    constructorWithArguments.append("  };\n");
    1.64 +                    if (parameterCount < 255) {
    1.65 +                        w.write(constructorWithArguments.toString());
    1.66 +                    }
    1.67                  }
    1.68                  w.append("  private static class Html4JavaType extends org.netbeans.html.json.spi.Proto.Type<").append(className).append("> {\n");
    1.69                  w.append("    private Html4JavaType() {\n      super(").append(className).append(".class, ").