// Path: ajuda.ai/payment-api/src/main/java/ajuda/ai/payment/exception/UnsupportedPaymentServiceException.java
// public class UnsupportedPaymentServiceException extends RuntimeException {
// 	private static final long serialVersionUID = 5985711746057579224L;
// 
// 	public UnsupportedPaymentServiceException() {
// 		super();
// 	}
// 
// 	public UnsupportedPaymentServiceException(String arg0, Throwable arg1, boolean arg2, boolean arg3) {
// 		super(arg0, arg1, arg2, arg3);
// 	}
// 
// 	public UnsupportedPaymentServiceException(String arg0, Throwable arg1) {
// 		super(arg0, arg1);
// 	}
// 
// 	public UnsupportedPaymentServiceException(String arg0) {
// 		super(arg0);
// 	}
// 
// 	public UnsupportedPaymentServiceException(Throwable arg0) {
// 		super(arg0);
// 	}
// }


import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import ajuda.ai.payment.exception.UnsupportedPaymentServiceException;

package ajuda.ai.payment;



/**
 * Mantém um registro dos serviços de pagamento e instancia as implementações.
 * 
 * @author Rafael Lins
 *
 */
@ApplicationScoped
public class PaymentService {
	@Inject @ajuda.ai.payment.annotation.PaymentService
	private Instance<PaymentGateway> processors;
	
	/**
	 * @param service Serviço de pagamento
	 * @return Um {@link PaymentGateway} do serviço especificado
	 */
	public PaymentGateway get(String service) {
		for (PaymentGateway paymentProcessor : processors) {
			ajuda.ai.payment.annotation.PaymentService annotation = paymentProcessor.getClass().getAnnotation(ajuda.ai.payment.annotation.PaymentService.class);
			
			if (annotation.value().equals(service)) {
				return paymentProcessor;
			}
		}
		

// Path: ajuda.ai/payment-api/src/main/java/ajuda/ai/payment/exception/UnsupportedPaymentServiceException.java
// public class UnsupportedPaymentServiceException extends RuntimeException {
// 	private static final long serialVersionUID = 5985711746057579224L;
// 
// 	public UnsupportedPaymentServiceException() {
// 		super();
// 	}
// 
// 	public UnsupportedPaymentServiceException(String arg0, Throwable arg1, boolean arg2, boolean arg3) {
// 		super(arg0, arg1, arg2, arg3);
// 	}
// 
// 	public UnsupportedPaymentServiceException(String arg0, Throwable arg1) {
// 		super(arg0, arg1);
// 	}
// 
// 	public UnsupportedPaymentServiceException(String arg0) {
// 		super(arg0);
// 	}
// 
// 	public UnsupportedPaymentServiceException(Throwable arg0) {
// 		super(arg0);
// 	}
// }


// Path: ajuda.ai/payment-api/src/main/java/ajuda/ai/payment/PaymentService.java
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import ajuda.ai.payment.exception.UnsupportedPaymentServiceException;

package ajuda.ai.payment;



/**
 * Mantém um registro dos serviços de pagamento e instancia as implementações.
 * 
 * @author Rafael Lins
 *
 */
@ApplicationScoped
public class PaymentService {
	@Inject @ajuda.ai.payment.annotation.PaymentService
	private Instance<PaymentGateway> processors;
	
	/**
	 * @param service Serviço de pagamento
	 * @return Um {@link PaymentGateway} do serviço especificado
	 */
	public PaymentGateway get(String service) {
		for (PaymentGateway paymentProcessor : processors) {
			ajuda.ai.payment.annotation.PaymentService annotation = paymentProcessor.getClass().getAnnotation(ajuda.ai.payment.annotation.PaymentService.class);
			
			if (annotation.value().equals(service)) {
				return paymentProcessor;
			}
		}
		

		throw new UnsupportedPaymentServiceException(service);
