package com.bonus.canteen.core.marketing.v2.rule.price.handler.deductionfull.constants;

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

public enum PriceTypeEnum {
   PRICE_TYPE_STEP(1, "阶梯"),
   PRICE_TYPE_CYCLE(2, "循环");

   private final Integer key;
   private final String value;

   public static String getValueByKey(Integer key) {
      Optional<PriceTypeEnum> type = Arrays.stream(values()).filter((e) -> {
         return Objects.equals(e.key, key);
      }).findFirst();
      return type.isPresent() ? ((PriceTypeEnum)type.get()).getValue() : "";
   }

   public Integer getKey() {
      return this.key;
   }

   public String getValue() {
      return this.value;
   }

   private PriceTypeEnum(final Integer key, final String value) {
      this.key = key;
      this.value = value;
   }

}
