Xtend help [message #704833] |
Fri, 29 July 2011 01:55  |
Eclipse User |
|
|
|
Hi,
In my model i have different types. For each type i will have to get the filepath, scope etc. which are common to all types. I use xtend along with JAVA to get the filepath and other details. Do i have to write methods to get the filepath and others for each Type.? Is it possible to do it in a generic way?, instead of repeating methods for each Type.
Model :
name=ID
(packages+=Package)*;
Package:
"package" name=QualifiedName '{'
(types+=Type)*
'}';
Type:
DataType | Droplet | FormHandler | Properties | JSP | Schedular | GenericService | MessageSource | MessageSink | MessageSourceSink | DynamoMessageConfig ;
========================
Xpand template
==============
«DEFINE droplet FOR Droplet»
«FILE getPropertyFilePath()+ getPropertyFileName() +".properties"»
«ENDFILE»
«ENDDEFINE»
«DEFINE formhandler FOR FormHandler»
«FILE getPropertyFilePath()+ getPropertyFileName() +".properties"»
«ENDFILE»
«ENDDEFINE»
«DEFINE schedular FOR Schedular»
«FILE getPropertyFilePath()+ getPropertyFileName() +".properties"»
«ENDFILE»
«ENDDEFINE»
=========================
Xtend
=======
boolean getPropertyFileName(Droplet d) :
JAVA com.JavaUtil.getPropertyFileName(com.atgdsl.atgDsl.Droplet);
boolean getPropertyFileName(FormHandler f) :
JAVA com.JavaUtil.getPropertyFileName(com.atgdsl.atgDsl.FormHandler);
boolean getPropertyFileName(Schedular s) :
JAVA com.JavaUtil.getPropertyFileName(com.atgdsl.atgDsl.Schedular);
//Instead of writing the above ones, can't we do it with Type like below and get the file path for respective Type.
boolean getPropertyFileName(Type t) :
JAVA com.JavaUtil.getPropertyFileName(com.atgdsl.atgDsl.Type);
I don't want to do isntanceof check and type casting.
Thanks,
Arun
|
|
|
Re: Xtend help [message #704847 is a reply to message #704833] |
Fri, 29 July 2011 02:11  |
Eclipse User |
|
|
|
Hi,
hi, if you need the type information in java in order to calculate the stuff, you either have to do type checking/casting, or you have to write one java extension for every type.
If you don't need the type information, you could simply write one extension for Type, as that seems to be the super type of all of them.
Alex
|
|
|
Powered by
FUDForum. Page generated in 0.06936 seconds