Creating a Java Class Programmatically by means of Java Model [message #1100258] |
Mon, 02 September 2013 18:53  |
Eclipse User |
|
|
|
Hello guys.
Now I am having another issue. Now I don't know how to instantiate the class Type programmatically. I'am trying to create a Java class by means of Java Model. Thus, firstly, I created an instance of ClassDeclaration. Then, I set all information of this class, such visibility, also instantiated the Class Modifier to set the ClassDeclaration with the keywords Abstract and Public. But I'm facing an issue and I need to create an attribute to this Class. I know that I have to instantiate an FieldDeclaration, this is done. THe real problem is to instantiate the classes TypeAccess and Type.
See the source-code bellow:
Modifier modifierClass = JavaFactory.eINSTANCE.createModifier();
modifierClass.setInheritance(InheritanceKind.ABSTRACT);
modifierClass.setVisibility(VisibilityKind.PUBLIC);
modifierClass.setStatic(false);
modifierClass.setTransient(false);
modifierClass.setVolatile(false);
modifierClass.setNative(false);
modifierClass.setStrictfp(false);
modifierClass.setSynchronized(false);
Modifier modifierAtt = JavaFactory.eINSTANCE.createModifier();
modifierAtt.setVisibility(VisibilityKind.PRIVATE);
modifierAtt.setInheritance(InheritanceKind.NONE);
modifierAtt.setStatic(false);
modifierAtt.setTransient(false);
modifierAtt.setVolatile(false);
modifierAtt.setNative(false);
modifierAtt.setStrictfp(false);
modifierAtt.setSynchronized(false);
FieldDeclaration attibute1 = JavaFactory.eINSTANCE.createFieldDeclaration();
attibute1.setModifier(modifierAtt);
attibute1.setName("kind");
attibute1.setType(typeAcessFinal);
ClassDeclaration classDecl = JavaFactory.eINSTANCE.createClassDeclaration();
classDecl.setName("Animal");
classDecl.setModifier(modifierClass);
classDecl.getBodyDeclarations().add(attibute1);
Thus, how to instantiate the the class Type programmatically?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10111 seconds