package com.github.blindpirate.gogradle.util;

import com.github.blindpirate.gogradle.general.PickyFactory;
import com.google.common.base.Optional;

import java.util.List;

public class FactoryUtil {

    public static class NoViableFactoryException extends RuntimeException {
        public NoViableFactoryException(String message) {
            super(message);
        }
    }

    public static <MATERIAL, PRODUCT> Optional<PRODUCT> produce(
            List<? extends PickyFactory<MATERIAL, PRODUCT>> factories, MATERIAL material) {
        for (PickyFactory<MATERIAL, PRODUCT> factory : factories) {
            if (factory.accept(material)) {
                return Optional.of(factory.produce(material));
            }
        }
        return Optional.absent();
    }
}

@@ -197,188 +197,8 @@
 l %7B%0A
-%0A    public static class NoViableFactoryException extends RuntimeException %7B%0A        public NoViableFactoryException(String message) %7B%0A            super(message);%0A        %7D%0A    %7D%0A%0A
     
@@ -290,32 +290,40 @@
 ds PickyFactory%3C
+? super 
 MATERIAL, PRODUC
@@ -384,16 +384,24 @@
 Factory%3C
+? super 
 MATERIAL

modify generic declaration of a argument