1.1 --- a/json/src/main/java/net/java/html/json/Model.java Fri Dec 19 18:21:23 2014 +0100
1.2 +++ b/json/src/main/java/net/java/html/json/Model.java Thu Nov 05 23:38:18 2015 +0100
1.3 @@ -48,7 +48,6 @@
1.4 import java.lang.annotation.Target;
1.5 import java.net.URL;
1.6 import java.util.List;
1.7 -import org.netbeans.html.json.spi.Technology;
1.8
1.9 /** Defines a model class that represents a single
1.10 * <a target="_blank" href="http://en.wikipedia.org/wiki/JSON">JSON</a>-like object
1.11 @@ -222,4 +221,30 @@
1.12 * @since 1.1
1.13 */
1.14 String targetId() default "";
1.15 +
1.16 + /** Controls whether builder-like setters shall be generated. Once this
1.17 + * attribute is set, all {@link #properties()} will get a builder like
1.18 + * setter (takes value of the property and returns <code>this</code>
1.19 + * so invocations can be chained). When this attribute is specified,
1.20 + * the non-default constructor isn't generated at all.
1.21 + * <p>
1.22 + * Specifying <code>builder="assign"</code>
1.23 + * and having {@link #properties() properties} <code>name</code> and
1.24 + * <code>age</code> will generate method: <pre>
1.25 + * <b>public</b> MyModel assignName(String name) { ... }
1.26 + * <b>public</b> MyModel assignAge(int age) { ... }
1.27 + * </pre>
1.28 + * These methods can then be chained as <pre>
1.29 + * MyModel m = <b>new</b> MyModel().assignName("name").assignAge(3);
1.30 + * </pre>
1.31 + * The <code>builder</code> attribute can be set to empty string <code>""</code> -
1.32 + * then it is possible that some property names clash with Java keywords.
1.33 + * It's responsibility of the user to specify valid builder prefix,
1.34 + * so the generated methods are compilable.
1.35 + *
1.36 + * @return the prefix to put before {@link Property property} names when
1.37 + * generating their builder methods
1.38 + * @since 1.3
1.39 + */
1.40 + String builder() default "";
1.41 }