//since our bean cannot inherit the method json() from JsoModelBase, we have to block this getter
if(method.getName().equals("json")) continue;
if (isGetter(method)) {
JPrimitiveType pType = method.getReturnType().isPrimitive();
if (pType != null) {
if (pType != JPrimitiveType.BOOLEAN) {
sw.println("final public "
+ pType.getSimpleSourceName() + " "
+ method.getName() + "" + "() {");
sw.indent();
sw.println("return (" + pType.getSimpleSourceName()
+ ") json().getNumber("
+ quotedFieldName(method) + ");");
sw.outdent();
sw.println("}");
} else if (pType == JPrimitiveType.BOOLEAN) {
sw.println("final public boolean " + method.getName()
+ "() {");
sw.indent();
sw.println("return json().getBoolean("
+ quotedFieldName(method) + ");");
sw.outdent();
sw.println("}");
} else {
// shouldn't reach here (only void left)
throw new UnableToCompleteException();
}
} else {
JClassType cType = method.getReturnType()
.isClassOrInterface();
if (cType.isAssignableTo(types.stringType)) {
sw.println("final public String " + method.getName()
+ "() {");
sw.indent();
sw.println("return json().getString("
+ quotedFieldName(method) + ");");
sw.outdent();
sw.println("}");
} else {
sw.println("final public "
+ method.getReturnType()
.getParameterizedQualifiedSourceName()
+ " " + method.getName() + "" + "() {");
sw.indent();
generateDependentType(logger, context, types, method
.getReturnType().isClassOrInterface());
sw.println("return Util.reinterpret_cast(json().get("
+ quotedFieldName(method) + "))" + ";");
sw.outdent();
sw.println("}");
// handle arrays
// handle nested models
}
}
} else if (isSetter(method)) {
JPrimitiveType pType = method.getParameters()[0].getType()
.isPrimitive();
if (pType != null) {
if (pType != JPrimitiveType.BOOLEAN) {
sw.println("final public " + fluentOrVoid(method,simpleName) + " "
+ method.getName() + "("
+ pType.getSimpleSourceName() + " arg) {");
sw.indent();
sw.println("json().put(" + quotedFieldName(method)
+ ", arg);");
maybeFluentReturn(sw, method);
sw.outdent();