package com.bonus.core.marketing.v2.rule.recharge.handler;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

@Service
public class RuleRechargeProvider {
   @Resource
   private List<RuleRechargeHandler> ruleRechargeHandlers;

   public RuleRechargeProvider(){
      System.out.println("RuleRechargeProvider");
   }

   public RuleRechargeHandler getMarketRechargeHandler(Integer ruleType) {
      return this.ruleRechargeHandlers.stream().filter((e) -> {
         return Objects.equals(ruleType, e.getRuleType());
      }).findFirst().orElse(null);
   }
}
