如:
loanChannelVo.setStatusName(CommonUtil.getEnumDesc(LoanChannelStatusEnum.class, l/** * 根据枚举Class和code获取desc * * @param clazz * @param code * @return */ public static String getEnumDesc(Class clazz, Integer code) { try { Object[] enumList = clazz.getEnumConstants(); Method codeMethod = clazz.getMethod("getCode"); Method descMethod = clazz.getMethod("getDesc"); for (Object obj : enumList) { int enumCode = Integer.parseInt(codeMethod.invoke(obj).toString()); if (code == enumCode) { return descMethod.invoke(obj).toString(); } } } catch (Exception e) { logger.error("getEnumDesc error", e); } return ""; }
oanChannelVo.getStatus()));
07-06
892