java中枚举(enum)小例子。之前学过枚举但是一直没用,这里有个枚举类帮你我理解下(很肤浅)

直接上枚举类,代码简单易懂。

package com.jy.modules.cims.data.interact.tbj.loan.request;

/**
*
* @author shengzhoutao
*
*/
public enum RequestMethodORMEnum {
/** 接收募集计划申请 */
METHOD_TBJ_LOAN_RAISE_PLAN {
public String getRequestMethod() {
return "tbj.loan.raise.plan";
} public String getServiceMethod() {
return "doAuditResult";
} public Class<?> getServiceParameterClass() {
return RequestRaisePlanDTO.class;
} public String getServiceDesc() {
return "接收募集计划申请";
}
}, /** 接收贷款审批结果 */
METHOD_TBJ_LOAN_AUDIT_RESULT {
public String getRequestMethod() {
return "tbj.loan.audit.result";
} public String getServiceMethod() {
return "doAuditResult";
} public Class<?> getServiceParameterClass() {
return RequestAuditResultDTO.class;
} public String getServiceDesc() {
return "接收贷款审批结果";
}
}, /** 接收贷款放款结果 */
METHOD_TBJ_LOAN_LOAN_RESULT {
public String getRequestMethod() {
return "tbj.loan.loan.result";
} public String getServiceMethod() {
return "doLoanResult";
} public Class<?> getServiceParameterClass() {
return RequestLoanResultDTO.class;
} public String getServiceDesc() {
return "接收贷款放款结果";
}
}, /** 接收产品相关的债权信息 */
METHOD_TBJ_LOAN_PROD_LOAN {
public String getRequestMethod() {
return "tbj.loan.prod.loan";
} public String getServiceMethod() {
return "doProdLoan";
} public Class<?> getServiceParameterClass() {
return RequestProdLoanDTO.class;
} public String getServiceDesc() {
return "接收产品相关的债权信息";
}
}, /** 接收债权匹配信息 */
METHOD_TBJ_LOAN_TRADE_DEBTOR {
public String getRequestMethod() {
return "tbj.loan.trade.debtor";
} public String getServiceMethod() {
return "doTradeDebtor";
} public Class<?> getServiceParameterClass() {
return RequestTradeDebtorDTO.class;
} public String getServiceDesc() {
return null;
}
}; // 获取请求方法
public abstract String getRequestMethod(); // 获取请求描述
public abstract String getServiceDesc(); // 获取服务方法
public abstract String getServiceMethod(); // 获取服务参数Class
public abstract Class<?> getServiceParameterClass(); }

可以直接调用

RequestMethodORMEnum.METHOD_TBJ_LOAN_AUDIT_RESULT.getServiceDesc();

上一篇:Spark源码学习1.6——Executor.scala


下一篇:Java 虚拟机系列二:垃圾收集机制详解,动图帮你理解