I have an application that is made with reflection as i made it to work for multiple versions. it uses many methods, so i wanted to know what is the best way to cache methods, there are more than 80 methods, and I am currently using something like this, but when there are a lot of methods this looks very meshy and in terms of readibility it looks very bad. I would like to know if there is a better way thanks!.
HashMap<String, Method> methodHashMap = new HashMap<>();
Class<?> userClass = Class.forName("org.minecraft.users.User");
methodHashMap.put("getId", userClass.getMethod("getId"));
methodHashMap.put("getName", userClass.getMethod("getName"));
methodHashMap.put("getCoins", userClass.getMethod("getCoins"));
...
etc
Aucun commentaire:
Enregistrer un commentaire