With the goal xpp3-reader the set method of the bean is called before the collection has been populated. For example the following pattern is generated:
java.util.List<MojoDescriptor> mojos = new java.util.ArrayList<MojoDescriptor>();
pluginDescriptor.setMojos( mojos );
while ( parser.nextTag() == XmlPullParser.START_TAG )
{
if ( "mojo".equals( parser.getName() ) )
{
mojos.add( parseMojoDescriptor( parser, strict ) );
}
else
{
checkUnknownElement( parser, strict );
}
}
when using the following model:
<field xdoc.separator="blank">
<name>mojos</name>
<version>1.0.0+</version>
<association>
<type>MojoDescriptor</type>
<multiplicity>*</multiplicity>
</association>
<description>Description of each Mojo provided by the plugin.</description>
</field>
The code fails if the called setter method does not just add the reference to the collection but copies/processes the given argument.
Therefore the setter method should be called only after population (i.e. after the while loop).
The code is being generated in
|
private void writeNewSetLocation( String key, String objectName, String trackerVariable, JSourceCode sc ) |
.
With the goal
xpp3-readerthe set method of the bean is called before the collection has been populated. For example the following pattern is generated:when using the following model:
The code fails if the called setter method does not just add the reference to the collection but copies/processes the given argument.
Therefore the setter method should be called only after population (i.e. after the while loop).
The code is being generated in
modello/modello-plugins/modello-plugin-xpp3/src/main/java/org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java
Line 1639 in b405413