| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package com.goafanti.common.enums;
- import java.util.HashMap;
- import java.util.Map;
- import org.apache.commons.lang3.StringUtils;
- public enum BannersStatus {
-
- HOME( 1,"home"),
- OTHER(0, "other");
- private BannersStatus(Integer code, String desc) {
- this.code = code;
- this.desc = desc;
- }
- private static Map<Integer, BannersStatus> status = new HashMap<Integer, BannersStatus>();
- static {
- for (BannersStatus value : BannersStatus.values()) {
- status.put(value.getCode(), value);
- }
- }
- public static BannersStatus getStatus(Integer code) {
- if (containsType(code)) {
- return status.get(code);
- }
- return OTHER;
- }
- public static BannersStatus getStatus(String code) {
- if (StringUtils.isNumeric(code)) {
- return getStatus(Integer.parseInt(code));
- }
- return OTHER;
- }
- public static boolean containsType(Integer code) {
- return status.containsKey(code);
- }
- private Integer code;
- private String desc;
- public Integer getCode() {
- return code;
- }
- public String getDesc() {
- return desc;
- }
- }
|