// switch(fieldId)
List<CaseStatement> cases = new ArrayList<>();
for (ThriftFieldMetadata field : metadata.getFields(THRIFT_FIELD)) {
cases.add(caseStatement(field.getId(), field.getName() + "-write-field"));
}
write.switchStatement("default-write", cases);
// write fields
for (ThriftFieldMetadata field : metadata.getFields(THRIFT_FIELD)) {
write.visitLabel(field.getName() + "-write-field");
writeField(write, protocol, field);