标签:tco == pack imp equal script ret 获得 port
1 package com.uwillbe.pad.enums; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 /** 7 * @Author: 姿势帝 8 * @Description: 9 * @Date: Create in 14:36 2019/1/27 10 */ 11 public enum GroupEnum { 12 /** 13 * 分组id与分组名称 14 */ 15 GROUP_1(1, "物化历"), 16 GROUP_2(2, "物化地"), 17 GROUP_3(3, "物生历"), 18 GROUP_4(4, "物政历"), 19 GROUP_5(5, "物历地"), 20 GROUP_6(6, "物生政"), 21 GROUP_7(7, "物生地"), 22 GROUP_8(8, "物政地"), 23 GROUP_9(9, "物化政"), 24 GROUP_10(10, "物化生"), 25 GROUP_11(11, "化生历"), 26 GROUP_12(12, "化政历"), 27 GROUP_13(13, "化生政"), 28 GROUP_14(14, "化政地"), 29 GROUP_15(15, "化历地"), 30 GROUP_16(16, "化生地"), 31 GROUP_17(17, "生历地"), 32 GROUP_18(18, "生政地"), 33 GROUP_19(19, "生政历"), 34 GROUP_20(20, "政历地"); 35 36 37 38 /** 枚举值 */ 39 private final Integer code; 40 41 /** 枚举描述 */ 42 private final String message; 43 44 /** 45 * 构造方法 46 * @param code 47 * @param message 48 */ 49 GroupEnum(Integer code, String message) { 50 this.code = code; 51 this.message = message; 52 } 53 54 public Integer getCode() { 55 return code; 56 } 57 58 public String getMessage() { 59 return message; 60 } 61 62 /** 63 * 通过code获取msg 64 * 65 * @param code 枚举值 66 * 67 * @return 68 */ 69 public static String getMsgByCode(Integer code) { 70 if (code == null) { 71 return null; 72 } 73 GroupEnum enumList = getByCode(code); 74 if (enumList == null) { 75 return null; 76 } 77 return enumList.getMessage(); 78 } 79 80 /** 81 * 通过枚举<code>code</code>获得枚举 82 * 83 * values() 方法将枚举转变为数组 84 * 85 * @return AuthGradeEnum 86 */ 87 public static GroupEnum getByCode(Integer code) { 88 for (GroupEnum enumList : values()) { 89 if (enumList.getCode().equals(code)) { 90 return enumList; 91 } 92 } 93 return null; 94 } 95 96 /** 97 * 获取全部枚举 98 * 99 * @return List<AuthGradeEnum> 100 */ 101 public static List<GroupEnum> getAllEnum() { 102 List<GroupEnum> list = new ArrayList<>(values().length); 103 for (GroupEnum enumList : values()) { 104 list.add(enumList); 105 } 106 return list; 107 } 108 109 /** 110 * 获取全部枚举值 111 * 112 * @return List<String> 113 */ 114 public static List<Integer> getAllEnumCode() { 115 List<Integer> list = new ArrayList<>(values().length); 116 for (GroupEnum enumList : values()) { 117 list.add(enumList.getCode()); 118 } 119 return list; 120 } 121 122 123 }
标签:tco == pack imp equal script ret 获得 port
原文地址:https://www.cnblogs.com/newAndHui/p/10326654.html