package com.bonus.canteen.core.marketing.v2.rule.pay.handler;

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

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

@Service
public class RulePayProvider {
   @Autowired
   private List<RulePayHandler> rulePayHandlers;

   public RulePayHandler getMarketPayHandler(Integer ruleType) {
      return (RulePayHandler)this.rulePayHandlers.stream().filter((e) -> {
         return Objects.equals(ruleType, e.getRuleType());
      }).findFirst().orElse(null);
   }
}
