package com.red.circle.common.business.enums;

import com.red.circle.tool.core.text.StringPool;
import java.util.Arrays;
import java.util.Objects;

/**
 * @author pengliang on 2019/12/25 14:57
 */
public enum IncomeExpenditureEnum {
  INCOME(0, "收入"),
  EXPENDITURE(1, "支出");

  private final int value;
  private final String des;

  IncomeExpenditureEnum(int value, String des) {
    this.value = value;
    this.des = des;
  }

  public int getValue() {
    return value;
  }

  public String getDes() {
    return des;
  }

  public boolean eq(Integer val) {
    return Objects.equals(this.value, val);
  }

  public static String getDes(Integer val) {
    return Arrays.stream(IncomeExpenditureEnum.values())
        .filter(incomeExpenditureEnum -> incomeExpenditureEnum.eq(val))
        .findFirst()
        .map(IncomeExpenditureEnum::getDes)
        .orElse(StringPool.EMPTY);
  }
}
