
package com.tmerclub.cloud.live.constant;

import java.util.Objects;

/**
 * 直播间状态 0.未开始 1.直播中 2.已结束 3.暂停中 -1.违规下架
 * @author lhd
 */
public enum LiveRoomStatusType {

    /**
     * 违规下架
     */
    OFFLINE(-1),

    /**
     * 未开始
     */
    NO_START(0),

    /**
     * 直播中
     */
    LIVING(1),

    /**
     * 已结束
     */
    FINISHED(2),

    /**
     * 暂停中
     */
    STOP(3),
    ;


    private final Integer num;

    public Integer value() {
        return num;
    }

    LiveRoomStatusType(Integer num){
        this.num = num;
    }

    public static LiveRoomStatusType instance(Integer value) {
        LiveRoomStatusType[] enums = values();
        for (LiveRoomStatusType statusEnum : enums) {
            if (statusEnum.value().equals(value)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static Boolean isNeedFinish(Integer value) {
        return Objects.equals(value, LiveRoomStatusType.STOP.value()) || Objects.equals(value, LiveRoomStatusType.LIVING.value()) || Objects.equals(value, LiveRoomStatusType.NO_START.value());
    }

    public static Boolean isNeedOpen(Integer value) {
        return Objects.equals(value, LiveRoomStatusType.STOP.value()) || Objects.equals(value, LiveRoomStatusType.NO_START.value());
    }
}
