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 DiscountTypeEnum {
   DISCOUNT_TYPE_REDUCTION(1, "满减"),
   DISCOUNT_TYPE_RATE(2, "满折");

   private final Integer key;
   private final String value;

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

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

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

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

}
