final NewMethodParameter objectOutputStream = newMethod.newParameter();
objectOutputStream.setFinal(true);
objectOutputStream.setName(SerializationConstants.CLIENT_OBJECT_WRITER_IMPL_WRITE_FIELDS_OBJECT_OUTPUT_STREAM_PARAMETER);
objectOutputStream.setType(this.getObjectOutputStream());
final WriteFieldsTemplatedFile body = new WriteFieldsTemplatedFile();
body.setType(type);
newMethod.setBody(body);
// add all fields to the template
final Iterator fields = this.filterSerializableFields(type.getFields()).iterator();
int fieldCount = 0;
context.branch();
while (fields.hasNext()) {
final Field field = (Field) fields.next();
final Method getter = this.createFieldGetter(writer, field);
body.addFieldGetter(getter);
fieldCount++;
}
context.unbranch();