1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| public class XxEnum {
@Getter @AllArgsConstructor public enum XxResult { R_400("400", "系统繁忙,请稍后再试"), ;
private final String code; private final String name; }
@Getter @AllArgsConstructor public enum XxType { CLIQUE("C", "拼团"), ;
private final String code; private final String name;
public static XxType getByCode(String code) { if (code != null && code.length() > 0) { for (XxType xxType : XxType.values()) { if (code.equals(xxType.getCode())) { return xxType; } } } return null; }
public static String[] getCodes() { List<String> codes = Lists.newArrayList(XxType.class.getEnumConstants()).stream().map(e -> e.getCode()).collect(Collectors.toList()); return Arrays.copyOf(codes.toArray(), codes.size(), String[].class); } } }
|