package com.vci.starter.web.enumpck;
|
|
import com.vci.starter.web.annotation.VciEnum;
|
|
/**
|
* 属性的类型
|
* @author weidy
|
* @date 2019/10/10 4:23 PM
|
*/
|
@VciEnum(name = "VciFieldType",text = "属性类型")
|
public enum VciFieldTypeEnum {
|
/**
|
* 字符串
|
*/
|
VTString,
|
/**
|
* 整形
|
*/
|
VTInteger,
|
/**
|
* 长整形
|
*/
|
VTLong,
|
/**
|
* 金额/双精度
|
*/
|
VTDouble,
|
/**
|
* 布尔型
|
*/
|
VTBoolean,
|
/**
|
* 日期
|
*/
|
VTDate,
|
/**
|
* 日期时间
|
*/
|
VTDateTime,
|
/**
|
* 时间
|
*/
|
VTTime,
|
/**
|
* 文件
|
*/
|
VTFilePath,
|
/**
|
* 超长文本
|
*/
|
VTClob;
|
|
/**
|
* 根据名称获取对应的枚举值
|
* @param text 名称
|
* @return 枚举值
|
*/
|
public static String getValueByText(String text){
|
if(text == null || text.trim().length() == 0){
|
return "";
|
}else{
|
if("布尔型".equalsIgnoreCase(text)){
|
return VTBoolean.name();
|
}else if("长文本".equalsIgnoreCase(text)){
|
return VTClob.name();
|
}else if("日期".equalsIgnoreCase(text)){
|
return VTDate.name();
|
}else if("日期时间".equalsIgnoreCase(text)){
|
return VTDateTime.name();
|
}else if("时间".equalsIgnoreCase(text)){
|
return VTTime.name();
|
}else if("长整型".equalsIgnoreCase(text)){
|
return VTLong.name();
|
}else if("金额/双精度".equalsIgnoreCase(text)){
|
return VTDouble.name();
|
}else if("整形".equalsIgnoreCase(text)){
|
return VTInteger.name();
|
}else if("文件".equalsIgnoreCase(text)){
|
return VTFilePath.name();
|
}else{
|
return VTString.name();
|
}
|
}
|
}
|
|
/**
|
* 根据枚举值获取名称
|
* @param value 枚举值
|
* @return 名称
|
*/
|
public static String getTextByValue(String value){
|
VciFieldTypeEnum wenum = forValue(value);
|
if(wenum == null){
|
return "";
|
}
|
switch (wenum){
|
case VTBoolean:
|
return "布尔型";
|
case VTClob:
|
return "长文本";
|
case VTDate:
|
return "日期";
|
case VTDateTime:
|
return "日期时间";
|
case VTTime:
|
return "时间";
|
case VTLong:
|
return "长整型";
|
case VTDouble:
|
return "金额/双精度";
|
case VTInteger:
|
return "整形";
|
case VTFilePath:
|
return "文件";
|
default:
|
return "字符串";
|
}
|
}
|
|
/**
|
* 根据枚举值获取枚举对象
|
* @param value 枚举值
|
* @return 对应的枚举对象,不匹配的时候返回null
|
*/
|
public static VciFieldTypeEnum forValue(String value){
|
for(VciFieldTypeEnum wenum : VciFieldTypeEnum.values()){
|
if(wenum.name().equalsIgnoreCase(value)){
|
return wenum;
|
}
|
}
|
return null;
|
}
|
|
}
|