public enum TestInfoType { /**自定义描述信息*/ TYPE_01("1",PriorityEnum.PRIORITY_5.getValue()), /**自定义描述信息*/ TYPE_02("2",PriorityEnum.PRIORITY_5.getValue()), /**自定义描述信息*/ TYPE_03("3",PriorityEnum.PRIORITY_8.getValue()), /**自定义描述信息 */ TYPE_04("4",PriorityEnum.PRIORITY_20.getValue()), /**自定义描述信息*/ TYPE_05("5",PriorityEnum.PRIORITY_20.getValue()), /**自定义描述信息*/ TYPE_16("16",PriorityEnum.PRIORITY_14.getValue()); //状态码 private String code; //优先级 private Integer priority; /** * 私有构造器 * @param code */ private TestInfoType(String code,Integer priority){ this.code=code; this.priority=priority; } /* * get方法 */ public String getCode() { return code; } /*set方法 public void setCode(String code) { this.code = code; }*/ public Integer getPriority() { return priority; } /*set方法 public void setPriority(Integer priority) { this.priority = priority; }*/ public static TestInfoType getEnumByCode(String code) { if(StringUtils.isNotBlank(code)) { for (TestInfoType item : TestInfoType .values()) { if (item.getCode().equals(code)) { return item; } } } return null; } }
2、Demo02
public class TestConstants { public static final Integer TYPE_INT_CONTENT=8888; public static final String TYPE_STR_CONTENT="9999"; /** * 自定义注释 */ public abstract class Test01 { public static final String Test01_A="0"; public static final int Test01_B=1; } /** * 自定义注释 */ public static class Test02 { public static final String Test02_A="ADVANCE_BRANCH"; public static final String Test02_B="MODOU_SHARE_HTML"; } /** * 自定义注释 */ public static class Test03{ private Test03(){} public static final String Test03_A= "6"; } } 使用: Test01.Test01_A Test02.Test02_B