Method getSetMethod(Class<?> targetClass, Class<?> fieldType, String fieldName) { fieldName = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); String methodname = "set" + fieldName; Method method = null; try { method = targetClass.getMethod(methodname, new Class<?>[] {fieldType}); } catch (Exception e) { playerObjects.getLogFile().WriteLine(Formatting.exceptionToStackTrace(e)); } return method; }
Method getGetMethod(Class<?> targetClass, Class<?> fieldType, String fieldName) { fieldName = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); String methodname = "get" + fieldName; if (fieldType == boolean.class || fieldType == Boolean.class) { methodname = "is" + fieldName; } Method method = null; try { method = targetClass.getMethod(methodname, new Class<?>[0]); } catch (Exception e) { playerObjects.getLogFile().WriteLine(Formatting.exceptionToStackTrace(e)); } return method; }