valueExp = "m." + attr.getReadMethodName() + "()";
indent = 0;
JsonAnnotation ja = attr.getJson();
if (ja.isIgnore())
continue;
DataType dataType = attr.getDataType();
if(dataType instanceof InverseModelRefType && !ja.hasIgnore()){
continue;
}
String cn = ja.getCoderClassName();
coderExp = encoders.get(cn);
if (coderExp == null) {
String vn = "encoder" + encoders.size();
coderExp = vn;
printer.println("%s %s = new %1$s();", cn, vn);
encoders.put(cn, vn);
}
if (!(dataType instanceof CorePrimitiveType)
&& ja.isIgnoreNull()) {
printer.print("if(%s != null", valueExp);
if (dataType instanceof TextType) {
printer.printWithoutIndent(
" && %s.getValue() != null",
valueExp);
} else if (dataType instanceof BlobType) {
printer.printWithoutIndent(
" && %s.getBytes() != null",
valueExp);
} else if (dataType instanceof ModelRefType) {
printer.printWithoutIndent(
" && %s.getKey() != null",
valueExp);
} else if (dataType instanceof InverseModelRefType) {
printer.printWithoutIndent(
" && getKey(m) != null"
);
}
printer.printlnWithoutIndent("){");
printer.indent();
indent++;
}
String name = ja.getAlias();
if (name.length() == 0) {
name = attr.getAttributeName();
}
printer.println(
"writer.setNextPropertyName(\"%1$s\");",
name);
dataType.accept(this, attr);
for (int i = 0; i < indent; i++) {
printer.unindent();
printer.println("}");
}
}