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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class RulePriceProvider {
   @Autowired
   private List<RulePriceHandler> rulePriceHandlers;

   public RulePriceHandler getMarketPriceHandler(Integer ruleType) {
      return (RulePriceHandler)this.rulePriceHandlers.stream().filter((e) -> {
         return Objects.equals(ruleType, e.getRuleType());
      }).findFirst().orElse(null);
   }
}
