1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
public static Object invokeConvertMethod(String enumClazzName, Object methodParam) {
if (!methodCache.containsKey(enumClazzName)) {
throw new RuntimeException("Wrong");
}
try {
Method method = methodCache.get(enumClazzName);
// todo 临时,因为还没有决定枚举要不要分String和Integer
return method.invoke(null, String.valueOf(methodParam));
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return null;
}
}
|