enum枚举使用

package com.sf.ccsp.inter.enums;


import com.sf.ccsp.inter.commin.utils.StringUtils;


public enum AppointmentExceptionEnum {
    
E_0("客户无法满足疑似高价值快件寄递要求","40007"),/*客户无法满足疑似高价值快件寄递要求     */
E_12("特殊收派客户","40008"),/*特殊收派客户     */
E_20("托寄物与订单信息不符","40009"),/*托寄物与订单信息不符     */
E_27("代收货款手续不齐全(包括未签协议,无正规发票等)","40010"),/*代收货款手续不齐全(包括未签协议,无正规发票等)     */
E_37("在客户处等待五分钟,仍未准备好快件已知会客户需重新下单","40011"),/*在客户处等待五分钟,仍未准备好快件已知会客户需重新下单     */
E_43("包装不良","40012"),/*包装不良     */
E_44("客户不愿意开箱检查","40013"),/*客户不愿意开箱检查     */
E_46("客户取消寄件","40014"),/*客户取消寄件     */
E_47("客户重复下单","40015"),/*客户重复下单     */
E_53("下错单需重新下单","40016"),/*下错单需重新下单     */
E_90("客户无法提供有效身份证明文件","40017"),/*客户无法提供有效身份证明文件     */
E_101("快件超过规定尺寸或重量","40018");/*快件超过规定尺寸或重量     */
    
   private String cause ;
   private String responseCode ;
    
   private AppointmentExceptionEnum( String cause , String responseCode ){
       this.cause = cause ;
       this.responseCode = responseCode ;
   }


public String getCause() {
return cause;
}


public void setCause(String cause) {
this.cause = cause;
}


public String getResponseCode() {
return responseCode;
}


public void setResponseCode(String responseCode) {
this.responseCode = responseCode;
}

public static String getEnumCause(String responseCode) {
if (StringUtils.isEmpty(responseCode)) {
return E_46.getCause();
       }
for(AppointmentExceptionEnum item : AppointmentExceptionEnum.values()) {
if(item.getResponseCode().equals(responseCode)) {
return item.getCause();
}
}
return E_46.getCause();
}


}

猜你喜欢

转载自blog.csdn.net/robinsonxiao/article/details/54135417