package cn.com.goldenwater.dcproj.utils; import cn.com.goldenwater.dcproj.constValue.BisInspEnum; import cn.com.goldenwater.dcproj.constValue.BisInspTypeEnum; import org.apache.commons.lang3.StringUtils; import java.util.List; /** * Created by jinshui on 2019/8/20. */ public class EnumUtil { private EnumUtil(){ } /** * 获取枚举对象 * @param ptype * @return */ public static BisInspEnum getBisInspEnum(String ptype){ if (StringUtils.isBlank(ptype)) { return null; } for (BisInspEnum enums : BisInspEnum.values()) { if (enums.getValue().equals(ptype)) { return enums; } } return null; } public static BisInspTypeEnum getBisInspTypeEnum(String objType) { if (StringUtils.isBlank(objType)) { return null; } for (BisInspTypeEnum enums : BisInspTypeEnum.values()) { if (enums.getValue().equals(objType)) { return enums; } } return null; } /** * 判断ptype是否存在与枚举中 * @param ptype * @return */ public static boolean getFlag(String ptype) { if (StringUtils.isBlank(ptype)) { return false; } for (BisInspEnum enums : BisInspEnum.values()) { if (enums.getValue().equals(ptype)) { return true; } } return false; } /** * 判断ptype是否存在与枚举中,通过list过滤不需要判断的枚举类型 * @param ptype * @return */ public static boolean getFlag(String ptype, List list) { if (StringUtils.isBlank(ptype)) { return false; } if (list == null) { return false; } for (BisInspEnum enums : BisInspEnum.values()) { if (list.contains(enums.getKey())) { continue; } if (enums.getValue().equals(ptype)) { return true; } } return false; } }