package com.red.circle.console.infra.database.rds.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.red.circle.framework.mybatis.enums.IEnum;
import java.util.Arrays;
import java.util.Objects;

/**
 * <p>
 * 状态枚举.
 * </p>
 *
 * @author pengliang
 */
public enum StatusEnum implements IEnum {

  NORMAL(0), DISABLE(1);

  @EnumValue
  private final int value;

  StatusEnum(final int value) {
    this.value = value;
  }

  public static StatusEnum toEnum(int value) {
    return Arrays.stream(StatusEnum.values()).filter(val -> Objects.equals(val.getValue(), value))
        .findFirst()
        .orElse(null);
  }

  @Override
  @JsonValue
  public int getValue() {
    return this.value;
  }
}
