package com.red.circle.other.inner.enums.config;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * 打卡.
 *
 * @author pengliang on 2020/7/31
 */
public enum ClockInConfigEnum {

  CLOCK_IN_ONE_DAY(1),

  CLOCK_IN_TWO_DAY(2),

  CLOCK_IN_THREE_DAY(3),

  CLOCK_IN_FOUR_DAY(4),

  CLOCK_IN_FIVE_DAY(5),

  CLOCK_IN_SIX_DAY(6),

  CLOCK_IN_SEVEN_DAY(7);

  private final int day;

  ClockInConfigEnum(int day) {
    this.day = day;
  }

  public static ClockInConfigEnum getCandyClockInConfigEnumByDay(Integer day) {
    return Optional.ofNullable(day)
        .map(val ->
            Arrays.stream(ClockInConfigEnum.values())
                .filter(clockInConfigEnum -> Objects.equals(clockInConfigEnum.getDay(), val))
                .findFirst()
                .orElse(null)
        )
        .orElse(null);
  }

  public int getDay() {
    return day;
  }
}
