I need get all the gets() of a model in my code.
Ex:
Model.java
private int var1;
private int var2;
private int var3;
public getVar1()...
public getVar2()...
public getVar3()...
I need get all the gets() of a model in my code.
Ex:
Model.java
private int var1;
private int var2;
private int var3;
public getVar1()...
public getVar2()...
public getVar3()...
Something like this, maybe?
MyClass myClass = new MyClass();
Class objClass = myClass.getClass();
Set<Method> getMethods = new HashSet<Method>();
for (Method method : objClass.getMethods()) {
if(method.getName().contains("getVar")) {
getMethods.add(method);
}
}
EDIT:
above is wrong! I did not see the GWT tag. Apparently, there is a good API for reflection for GWT, and you may be able to use my code: