展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

枚举工具类

@Getter
public class DietitianCorrespondUserConst {

    @Getter
    public enum StateType {
        NO_STATE("0", "未开始"),
        STARTING_STATE("1", "服务中"),
        STOP_STATE("2", "已结束");
        private String code;
        private String description;

        StateType(String code, String description) {
            this.code = code;
            this.description = description;
        }

        public boolean equalWithCode(String code) {
            return null != code && this.code.equals(code);
        }

        public static StateType findByCode(Integer code) {
            Optional<StateType> status = Arrays.stream(StateType.values())
                    .filter(d -> null != code && d.getCode().equals(code))
                    .findAny();
            if (status.isPresent()) {
                return status.get();
            } else {
                return null;
            }
        }
    }

}
posted @ 2022-07-22 15:27  DogLeftover  阅读(21)  评论(0)    收藏  举报