This might seem weird, but I need this functionality. On the UI side, I am accepting a java class code and storing the same in backend rest call in a String "editorCode" and I am also passing methodName to my rest call.
So what I want to do, I want to check if the passed methodName is there in the string represented class code or not. The class may have any number of the method in it. So what could be the best way to check if that method is exactly there in the class or not.
This is what I mean -
String editorCode = "public class Test { public void test1(){ int a = 1;} public void test2(){int a=2;} public void test3(){ int a=3;} public void test4(){ int a=4;}}";
String methodName = "testMethod";
So basically here I want to check if my testMethod is in the editorCode or not. Is there any way to first convert my editorCode String to Test Class object and then look for testMethod() in the class using reflection or any other means.
Aucun commentaire:
Enregistrer un commentaire