fromMapFunc method
Implementation
JavaFunction fromMapFunc() {
return JavaFunction(
depth: depth + 1,
functionName: 'fromMap',
returnType: AstCustomType(className),
isPublic: true,
isStatic: true,
params: [Variable(AstMap(keyType: AstString()), 'map')],
body: (depth) => [
OneLine(
depth: depth + 1,
body: Variable(AstCustomType(className), 'result')
.javaDeclaration(newInstance: true)),
...privateFields.map((field) {
return OneLine(
depth: depth + 1,
body:
'result.${field.name} = map.containsKey("${field.name}") && map.get("${field.name}") != null ? ${field.type.realType().convertJavaJson2Obj(vname: 'map.get("${field.name}")', showGenerics: true)};');
}),
OneLine(depth: depth + 1, body: 'return result;')
]);
}