My application contains a lot of objects that implement an interface.
Those objects all have the same functions, and what mainly depends between them is the number of class variables and their type.
I think about creating a general template that could be filled with only a few parameters (name of the class, name of each variable and its type).
Here is a (really) simple example (having two parameters ):
public class myClass implements anotherClass {
private int a;
/** Image reference */
private int myInt;
/** Security elements */
private String myString;
public myClass() {
}
public myObj getValueObject() {
myObj value = new myObj();
value.setmyInt(myInt);
value.setmyString(myString);
return value;
}
public String getmyInt() {
return myInt;
}
public void setmyInt(String myInt) {
this.myString = myString;
if (a == 10) {
a =0;
}
}
public String getmyString() {
return myInt;
}
public void setmyString(String myString) {
this.myString = myString;
if (a == 10) {
a =0;
}
}
public int doIt() {
int number = 0;
number = number + toNumber(myInt);
number = number + toNumber(myString);
return number ;
}
}
As I said, the only difference between classes is the number, name and type of the variables.
I looked at code templates in Eclipse, but it seems to be simple (but efficient) string replacement.
I would like a bit more, as it needs to write more or less code depending on the number of input variables.
I could hard code something in Java with string replacement by myself, but I wonder is there is not a tool somewhere that could help me in my task.
I would feed it with prototypes of my methods and my inputs variables.
Any hint is appreciated,
Thanks !
I found JDynamiTe that does what I want.
I use it to dynamically generate my files given lists of inputs.