Class XjcNonNullGetterPlugin
- java.lang.Object
-
- com.sun.tools.xjc.Plugin
-
- ch.sharedvd.jaxbPlugins.nonNullGetter.XjcNonNullGetterPlugin
-
public class XjcNonNullGetterPlugin extends com.sun.tools.xjc.PluginSupport a non null getter in addition to the default (JavaBean) setter methods.
The initial idea is simply to add a "with*" method to the generated class for every "set*" method encountered, with the only functional difference of returning the class instance, instead of void.
Enhancement on 11 June 2006:
Provide fluent setter api for Lists, with support of variable arguments.This enhancement was suggested by Kenny MacLeod <kennym@kizoom.com>, and endorsed by Kohsuke Kawaguchi <Kohsuke.Kawaguchi@sun.com>. Here is quoted from the original request:
By default, XJC represents Lists by generating a getter method, but no setter. This is impossible to chain with fluent-api. How about the plugin generates a withXYZ() method for List properties, taking as it's parameters a vararg list. For example:
// This method is generated by vanilla XJC public List<OtherType> getMyList() { if (myList == null) { myList = new ArrayList<OtherType>(); } return myList; } // This would be generated by fluent-api public MyClass withMyList(OtherType... values) { for(OtherType value : values) { getMyList().add(value); } return this; }- Author:
- Hanson Char
-
-
Constructor Summary
Constructors Constructor Description XjcNonNullGetterPlugin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetOptionName()StringgetUsage()booleanrun(com.sun.tools.xjc.outline.Outline aOutline, com.sun.tools.xjc.Options opt, ErrorHandler errorHandler)
-
-
-
Method Detail
-
getOptionName
public String getOptionName()
- Specified by:
getOptionNamein classcom.sun.tools.xjc.Plugin
-
getUsage
public String getUsage()
- Specified by:
getUsagein classcom.sun.tools.xjc.Plugin
-
run
public boolean run(com.sun.tools.xjc.outline.Outline aOutline, com.sun.tools.xjc.Options opt, ErrorHandler errorHandler)- Specified by:
runin classcom.sun.tools.xjc.Plugin
-
-