0

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()...
gmlyra
  • 71
  • 1
  • 8

1 Answers1

1

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:

http://gwtreflection.sourceforge.net/

jn1kk
  • 5,012
  • 2
  • 45
  • 72