The class which I am analyzing:
public class Users{
private String name = "Jacob";
private String address = "711 11th Ave, New York";
private int age = 28;
public String verifyAgeLimit() {
String msg = (this.age < 16) ? " is not allwed to use it." : " is Allwed to use it.";
return this.name+msg;
}
public String showName() {
return "User name is:"+this.name;
}
public String showAddress() {
return this.address;
}
public String hello() {
return "Hello World";
}
}
I'm trying to get variable names using MethodDeclaration, but unable to do so.
public void visit(MethodDeclaration n, Object arg) {
System.out.println(n.getName().toString());//It displays the full method
super.visit(n, arg);
}
I am trying to get output for this is.
verifyAgeLimit() : this.name or name
verifyAgeLimit() : this.name or name
showAddress() : this.address or address
I tried to convert the whole method to sting and read the string to find out the names but it is getting too much complicated and very less accurate.
Is there any way to solve it?