}
private MethodDeclaration createReadFields(EmitContext context, ModelDeclaration model) {
assert context != null;
assert model != null;
ModelFactory f = context.getModelFactory();
SimpleName parameter = context.createVariableName("in"); //$NON-NLS-1$
List<Statement> statements = Lists.create();
for (PropertyDeclaration property : model.getDeclaredProperties()) {
SimpleName fieldName = context.getFieldName(property);
statements.add(new ExpressionBuilder(f, fieldName)
.method("readFields", parameter) //$NON-NLS-1$
.toStatement());
}
return f.newMethodDeclaration(
null,
new AttributeBuilder(f)
.annotation(context.resolve(Override.class))
.Public()
.toAttributes(),
Collections.<TypeParameterDeclaration>emptyList(),
Models.toType(f, void.class),
f.newSimpleName("readFields"), //$NON-NLS-1$
Arrays.asList(f.newFormalParameterDeclaration(
context.resolve(DataInput.class),
parameter)),
0,
Collections.singletonList(context.resolve(IOException.class)),
f.newBlock(statements));
}