MethodDeclaration toGXTmethod = ast.newMethodDeclaration();
toGXTmethod.setConstructor(false);
List modifiers = toGXTmethod.modifiers();
modifiers.add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
toGXTmethod.setName(ast.newSimpleName("toGXTModelBean"));
Type returnType = ast.newSimpleType(ast.newName(newType));
toGXTmethod.setReturnType2(returnType);
/*
* method body starting with the block
*/
org.eclipse.jdt.core.dom.Block block = ast.newBlock();
/*
* define the return value
*/
SimpleName returnValueName = ast.newSimpleName("newGXTBean");
VariableDeclarationFragment fragment = ast.newVariableDeclarationFragment();
fragment.setName(returnValueName);
ClassInstanceCreation newClassInstance = ast.newClassInstanceCreation();
newClassInstance.setType((Type)returnType.copySubtree(ast, returnType));
fragment.setInitializer(newClassInstance);
VariableDeclarationStatement returnValue = ast.newVariableDeclarationStatement(fragment);
returnValue.setType((Type)returnType.copySubtree(ast, returnType));
block.statements().add(returnValue);
/*
* call each get method in the original and pass the result to the new set method
*
*/