Skip to content

Commit

Permalink
Call setter with Collection argument only after Collection has been
Browse files Browse the repository at this point in the history
fully populated

This closes #266
  • Loading branch information
kwin authored and hboutemy committed Dec 30, 2022
1 parent 33c8523 commit c5ef5eb
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@ private void processField( ModelField field, XmlFieldMetadata xmlFieldMetadata,

String adder;

boolean requireSetter = false;

if ( wrappedItems )
{
sc.add( tagComparison );
Expand All @@ -738,7 +740,7 @@ private void processField( ModelField field, XmlFieldMetadata xmlFieldMetadata,
}
sc.add( associationType + " " + associationName + " = " + defaultValue + ";" );

sc.add( objectName + ".set" + capFieldName + "( " + associationName + " );" );
requireSetter = true;

adder = associationName + ".add";
}
Expand Down Expand Up @@ -792,8 +794,8 @@ private void processField( ModelField field, XmlFieldMetadata xmlFieldMetadata,

sc.add( associationName + " = " + defaultValue + ";" );

sc.add( objectName + ".set" + capFieldName + "( " + associationName + " );" );

requireSetter = true;
sc.unindent();
sc.add( "}" );

Expand Down Expand Up @@ -851,15 +853,14 @@ private void processField( ModelField field, XmlFieldMetadata xmlFieldMetadata,

sc.unindent();
sc.add( "}" );

sc.unindent();
sc.add( "}" );
}
else
if (requireSetter)
{
sc.unindent();
sc.add( "}" );
sc.add( objectName + ".set" + capFieldName + "( " + associationName + " );" );
}
sc.unindent();
sc.add( "}" );

}
else
{
Expand Down

0 comments on commit c5ef5eb

Please sign in to comment.