*/
protected void overrideWriteFieldsMethods(final NewConcreteType deserializer, final Type type) {
Checker.notNull("parameter:deserializer", deserializer);
Checker.notNull("parameter:type", type);
final GeneratorContext context = this.getGeneratorContext();
context.branch();
context.debug("Overriding " + Constants.WRITE_FIELDS_WRITE_METHODS + "() and creating list getters for type \""
+ deserializer.getName() + "\".");
final NewMethod writeFields = deserializer.newMethod();
writeFields.setAbstract(false);
writeFields.setFinal(false);
writeFields.setName(Constants.WRITE_FIELDS_WRITE_METHODS);
writeFields.setNative(false);
writeFields.setReturnType(context.getVoid());
writeFields.setStatic(false);
writeFields.setVisibility(Visibility.PROTECTED);
final NewMethodParameter instanceParameter = writeFields.newParameter();
instanceParameter.setFinal(true);
instanceParameter.setName(Constants.WRITE_FIELDS_INSTANCE_PARAMETER);
instanceParameter.setType(context.getObject());
final NewMethodParameter jsonObjectParameter = writeFields.newParameter();
jsonObjectParameter.setFinal(true);
jsonObjectParameter.setName(Constants.WRITE_FIELD_JSON_OBJECT_PARAMETER);
final Type jsonObjectType = this.getJsonObject();
jsonObjectParameter.setType(jsonObjectType);
final WriteFieldsTemplatedFile body = new WriteFieldsTemplatedFile();
body.setInstanceType(type);
writeFields.setBody(body);
// find all fields belonging to type
final Iterator fields = type.getFields().iterator();
while (fields.hasNext()) {
final Field field = (Field) fields.next();
if (field.isStatic() || field.isTransient()) {
continue;
}
final NewMethod fieldGetter = this.createFieldGetter(deserializer, field);
final String javascriptPropertyName = this.getJavascriptPropertyName(field);
final Type serializer = this.getSerializer(field);
body.addField(javascriptPropertyName, fieldGetter, serializer);
} // while
context.unbranch();
}