private List getBeanPropertyInitStatements(WidgetAdapter adapter, TypeDeclaration type) {
List statements;
if (adapter.isRoot()) {
MethodDeclaration initMethod = getMethodDeclaration(type, INIT_METHOD_NAME);
if (initMethod != null) {
Block body = initMethod.getBody();
statements = body.statements();
} else {
initMethod = getMethodDeclaration(type, type.getName().getFullyQualifiedName());
if (initMethod != null) {
Block body = initMethod.getBody();
statements = body.statements();
} else {
statements = new ArrayList();
}
}
} else {
String getMethodName = NamespaceUtil.getGetMethodName(adapter, adapter.getID());
MethodDeclaration getMethod = getMethodDeclaration(type, getMethodName);
if (getMethod != null) {
Block body = getMethod.getBody();
statements = body.statements();
if (!statements.isEmpty()) {
Object first = statements.get(0);
if (first instanceof IfStatement) {
IfStatement ifs = (IfStatement) statements.get(0);
Statement thenstmt = ifs.getThenStatement();
if (thenstmt instanceof Block) {
Block block = (Block) thenstmt;
statements = block.statements();
}
}
}
} else {
MethodDeclaration initMethod = getMethodDeclaration(type, INIT_METHOD_NAME);
Block body = initMethod.getBody();
statements = body.statements();
}
}
return statements;
}