/**
 *
 */
package com.braintree.commands.factory;

import de.hybris.platform.payment.commands.Command;
import de.hybris.platform.payment.commands.factory.CommandFactory;
import de.hybris.platform.payment.commands.factory.CommandNotSupportedException;
import java.util.Map;

public class DefaultBrainTreeCommandFactory implements CommandFactory {

    private Map<Class<Command>, Command> graphQLCommands;
    private String paymentProvider;

    @Override
    public <T extends Command> T createCommand(Class<T> commandInterface) throws CommandNotSupportedException {

        T command = (T) graphQLCommands.get(commandInterface);

        if (command == null) {
            throw new CommandNotSupportedException("Command not implemented: " + commandInterface.getCanonicalName());
        }

        return command;
    }

    @Override
    public String getPaymentProvider() {
        return paymentProvider;
    }

    public void setPaymentProvider(String paymentProvider) {
        this.paymentProvider = paymentProvider;
    }

    public void setGraphQLCommands(
        Map<Class<Command>, Command> graphQLCommands) {
        this.graphQLCommands = graphQLCommands;
    }
}
