I'm in the process of creating an application but i've stumbled upon a problem.
I'm creating a program that will generate a .java file depending on the user input. In the program you'll be able to select custom api's (can't provide them to you though). Once you've selected an API call you'll have to specify the input for that method. You can also specify another API call as the input for the current parameter. I only want to show the api calls that provide the correct return value as an input for the selected api call. Here's the problem. I can detect the input type for the parameters of the selected api calls, but i can't seem to detect the type for the classValue parameter provided to listAPICallsWithReturnValue(...). the call.getMethod() function returns a java.lang.reflect.Method object.
I hope you all kinda understand what i mean... :)
public void displayParameterDialogs(APICall call) {
JDialogMethodParameters dialog = new JDialogMethodParameters(mainframe, true);
for (int i = 0; i < call.getMethod().getParameterTypes().length; i++) {
dialog.init(i, call.getMethod().getParameterTypes()[i]);
dialog.setVisible(true);
}
}
//dialog class
public void init(int parameterIndex, Class parameterType) {
this.jLabelInfo.setText("Data for input parameter: " + parameterIndex);
DefaultComboBoxModel cmodel = new DefaultComboBoxModel();
for (APICall call : TestFactory.getInstance().listAPICallsWithReturnValue(parameterType)) {
cmodel.addElement(call);
}
this.jComboBox1.setModel(cmodel);
}
public APICall[] listAPICallsWithReturnValue(Class<?> classValue) {
APICall[] calls;
Vector<APICall> temp = new Vector<APICall>();
Method[] methods = TestSuite.class.getMethods();
for (Method method : methods) {
System.out.println(method.getReturnType().getName());
System.out.println(classValue.getClass().getName());
System.out.println(classValue.toString());
if (method.getReturnType().getCanonicalName().equals(classValue.toString())) {
temp.add(new APICall(method));
}
}
calls = new APICall[temp.size()];
return temp.toArray(calls);
}