Class ValueConstructorPlugin
java.lang.Object
com.sun.tools.xjc.Plugin
org.jvnet.jaxb.plugin.value_constructor.ValueConstructorPlugin
public class ValueConstructorPlugin
extends com.sun.tools.xjc.Plugin
Generate two constructors for each generated class, one of which is a default constructor,
the other takes an argument for each field in the class and initialises the field with the
argument value.
Without this plugin, XJC will not generate any explicit constructors.
- Author:
- Kenny MacLeod $Id: XjcValueConstructorPlugin.java,v 1.7 2007-11-26 18:35:27 skaffman Exp $
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleangenerateConstructorParameter(com.sun.codemodel.JFieldVar field) Whether or not to generate a constructor parameter for the given field.protected Collection<com.sun.codemodel.JFieldVar> getInstanceFields(Collection<com.sun.codemodel.JFieldVar> fields) Takes a collection of fields, and returns a new collection containing only the instance (i.e. non-static) fields.protected List<com.sun.codemodel.JFieldVar> getSuperclassFields(com.sun.codemodel.JDefinedClass implClass) Retrieve a List of the fields of each ancestor class.getUsage()booleanrun(com.sun.tools.xjc.outline.Outline outline, com.sun.tools.xjc.Options options, ErrorHandler errorHandler) Methods inherited from class com.sun.tools.xjc.Plugin
getCustomizationURIs, isCustomizationTagName, onActivated, parseArgument, postProcessModel
-
Constructor Details
-
ValueConstructorPlugin
public ValueConstructorPlugin()
-
-
Method Details
-
getOptionName
- Specified by:
getOptionNamein classcom.sun.tools.xjc.Plugin
-
getUsage
- Specified by:
getUsagein classcom.sun.tools.xjc.Plugin
-
run
public boolean run(com.sun.tools.xjc.outline.Outline outline, com.sun.tools.xjc.Options options, ErrorHandler errorHandler) - Specified by:
runin classcom.sun.tools.xjc.Plugin
-
getInstanceFields
protected Collection<com.sun.codemodel.JFieldVar> getInstanceFields(Collection<com.sun.codemodel.JFieldVar> fields) Takes a collection of fields, and returns a new collection containing only the instance (i.e. non-static) fields.- Parameters:
fields- fields to get non-static fields- Returns:
- new List containing only non-static fields
-
generateConstructorParameter
protected boolean generateConstructorParameter(com.sun.codemodel.JFieldVar field) Whether or not to generate a constructor parameter for the given field.- Parameters:
field- field to test- Returns:
trueif we need to generate a constructor for the given field
-
getSuperclassFields
protected List<com.sun.codemodel.JFieldVar> getSuperclassFields(com.sun.codemodel.JDefinedClass implClass) Retrieve a List of the fields of each ancestor class. I walk up the class hierarchy until I reach a class that isn't being generated by JAXB.- Parameters:
implClass- the class to get fields from- Returns:
- List of fields in each ancestor class
-