您的位置:首页 > 编程语言 > Java开发

Java 枚举 String-String

2015-11-14 15:33 441 查看
package cn.bycs.online.dealer.vo;

/**
 * @author jiangxingqi
 *
 */
public enum NewcarOperationEnum {
         SYSTEM_DEFAULT("系统预置","1"),  
        SUBMIT_RELEASE("提交审核","2"),  
        PUBLISH_SUCCESS("审核通过","3"),  
        AUDIT_DENY("审核不通过","4");  
         
         private String key;  
        private String value;  
        
          
        private NewcarOperationEnum(String value,String key) {  
            this.value = value;  
            this.key = key;  
        }  
        
        /**
         * @param key the key to set
         */
        public void setKey(String key) {
            this.key = key;
        }

      
        /**
         * @return the key
         */  
        public String getKey() {  
            return key;  
        }  
      
          
        /**
         * @return the value
         */
        public String getValue() {
            return value;
        }

        /**
         * @param value the value to set
         */
        public void setValue(String value) {
            this.value = value;
        }

        

        public static String getValueByKey(String key) {  
            for (NewcarOperationEnum e : values()) {  
                if (e.getKey().equals(key)) {  
                    return e.getKey();
                }  
            }  
            return null;  
        }  
        public static String getKeyByValue(String value) {    
            for (NewcarOperationEnum e : values()) {    
                if (e.getValue().equals(value)) {    
                    return e.getKey();    
                }    
            }    
            return null;    
        }    
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: