java - How to print a type of getter -


i have code below:

public static void main(string[] args) throws exception {     printgetterssetters(podmiotszukajqueryformset.class); }  public static void printgetterssetters(class aclass) {     method[] methods = aclass.getmethods();      (method method: methods) {         if (isgetter(method)) {             system.out.println("getter: " + method);             }     } }  public static boolean isgetter(method method) {     if (!method.getname().startswith("getsomething")) {         return false;     }     if (method.getparametertypes().length != 0) return false;     if (void.class.equals(method.getreturntype())) return false;     return true; } 

output:

getter: public package.package.class package.package.class.getsomething()

how can type of getter, in example: "class" in other examples "string" , "int" etc.

--edit possible .getmodifiers() returns int. how can return string?

think looking the method getreturntype() of object java.lang.reflect.method

public class getreturntype()

returns class object represents formal return type of method represented method object.

returns:the return type method object represents


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -