Hi Jannes,
You could use the reflection concepts in Java to achieve something like that. But, you must also pass the method name of the class you want to execute for each object.
I have done similar stuff like this for a different case. I will try to give some steps as pointers, but please be informed that I did not tried this yet. With little bit of changes to the code below, it should be working
Class<?> objectClass = Class.forName(this.ClassName); // This returns the class that is needed
XPath<IMendixObject> xpath = XPath.create(this.getContext(), objectClass.getName()); //Verify if the objectClass,getName() gives you the required value. It must be Module.Entity name.
java.util.List<T> resultList = xpath.all();
Method instanceMethod = objectClass.getMethod("methodname"); // here you can define parameters for the method
for (int i = 0; i < resultList.size(); i++){
instanceMethod.invoke(result.get(i)); // I dont think casting might be needed. But you can check this while programming
}
Word of caution: java reflection must be handled properly.
Not directly the solution for the way you are trying to implement this currently, but have a look at https://www.mendix.com/blog/easy-xpath-retrieval-in-java/ to see an example of how this can be done differently and probably a bit easier than you are trying now.
Based on the TIOBE Index for June 2016 Java is now more well-known than a variety of widely-used programming languages, including C++, Python, C#, PHP and JavaScript. The statistics on usage posted on various websites illustrate the immense popularity and importance of Java in the present day world. Java is an all-purpose programming language. Certain developers prefer to use Java to build desktop GUI applications as well as other developers create numerous web-based applications using Java technologies. In addition, Java is also used extensively for the development of mobile applications and games for Android which is the mobile platform with the biggest user base. There are plenty of reasons that Java is going to be a major factor over an extended period of time.