package com.vci.starter.web.enumpck;
|
|
import com.vci.starter.web.annotation.VciEnum;
|
|
/**
|
* 密级管理
|
* @author weidy
|
*/
|
@VciEnum(name="Enumsecretgrade",text = "数据密级",description = "默认为非密,内部,秘密,机密;有些单位没有内部,则可以在配置文件中配置vciEnum.Enumsecretgrade.inner=false")
|
public enum DataSecretEnum implements BaseEnumInt{
|
|
/**
|
* 非密
|
*/
|
NONE(10,"非密"),
|
/**
|
* 内部
|
*/
|
INNER(15,"内部"),
|
/**
|
* 秘密
|
*/
|
SECRET(20,"秘密"),
|
/**
|
* 机密
|
*/
|
PRIVACY(30,"机密");
|
|
/**
|
* 枚举值
|
*/
|
private int value;
|
|
/**
|
* 枚举显示值
|
*/
|
private String text;
|
|
/**
|
* 获取枚举值
|
* @return 枚举值
|
*/
|
public int getValue() {
|
return value;
|
}
|
|
/**
|
* 设置枚举值
|
* @param value 枚举值
|
*/
|
public void setValue(int value) {
|
this.value = value;
|
}
|
|
/**
|
* 获取显示文本
|
* @return 显示文本
|
*/
|
public String getText() {
|
return text;
|
}
|
|
/**
|
* 设置显示文本
|
* @param text 显示文本
|
*/
|
public void setText(String text) {
|
this.text = text;
|
}
|
|
/**
|
* 枚举内部构造方法
|
* @param secret 枚举值
|
* @param secretText 显示文本
|
*/
|
private DataSecretEnum(int secret,String secretText){
|
this.value = secret;
|
this.text = secretText;
|
}
|
|
/**
|
* 根据枚举的值获取显示文本
|
* @param secret 枚举值
|
* @return 显示文本
|
*/
|
public static String getSecretText(int secret){
|
for(DataSecretEnum eu:DataSecretEnum.values()){
|
if(eu.value == secret){
|
return eu.text;
|
}
|
}
|
return NONE.text;
|
}
|
|
/**
|
* 根据枚举显示文本获取枚举值
|
* @param text 显示文本
|
* @return 枚举值
|
*/
|
public static int getSecretValueByText(String text){
|
for(DataSecretEnum eu:DataSecretEnum.values()){
|
if(eu.text.equalsIgnoreCase(text)){
|
return eu.value;
|
}
|
}
|
return NONE.value;
|
}
|
|
/**
|
* 是否有效的密级值
|
* @param secret 密级值
|
* @return 符合范围要求则返回true
|
*/
|
public static boolean isValid(int secret){
|
for(DataSecretEnum eu:DataSecretEnum.values()){
|
if(eu.value == secret){
|
return true;
|
}
|
}
|
return false;
|
}
|
}
|