I have to get the fully qualified name of the method parameter.
For example:
public void display(Custom1 a, Custom2 b) {
String x = a.getValue();
String y = b.getValue();
}
Here, Custom1
and Custom2
are in com.test.resource
so I need to get the value like
com.test.resource.Custom1
I am in need of this in my eclipse plugin.. I used IMethod.getParameterTypes()
. The result is like
QCustom1;
How can I get the fully qualified name of the method parameter?
String[] parameterNames = iMethod.getParameterNames();
ILocalVariable[] parameterTypes = currentmethod.getMethod().getParameters();
for (int j=0; j < parameterNames.length; ++j) {
System.out.println("parameter name:" + parameterNames[j]);
System.out.println("parameter type:" + parameterTypes[j]);
}
you can load the corresponding method using reflection and get the parameter value one by one.
if(method.getName().equals(iMethod.getMethodname())){
/**
* cheking whether the length of the parameter are equal
*/
if(method.getParameterTypes().length==iMethod.getParam().length){
/**
* getting the fully qualified name of the selected method paramater value
*/
Class<?>[] paramvalue=method.getParameterTypes();
for(int p=0;p<paramvalue.length;p++){
/**
* checking whether teh parameter are same for loading teh datastore
*/
if(paramvalue[p].getSimpleName().equals(temp)){
String fullyqualifiedname=paramvalue[p].getName();
}
}
}
}
}