package junitparams.internal.parameters;

import org.junit.runners.model.FrameworkMethod;

import junitparams.custom.ParametersProvider;
import junitparams.internal.annotation.CustomParametersDescriptor;
import junitparams.internal.annotation.FrameworkMethodAnnotations;

class ParametersFromCustomProvider implements ParametrizationStrategy {

    private final FrameworkMethodAnnotations frameworkMethodAnnotations;

    ParametersFromCustomProvider(FrameworkMethod frameworkMethod) {
        frameworkMethodAnnotations = new FrameworkMethodAnnotations(frameworkMethod);
    }

    @Override
    public boolean isApplicable() {
        return frameworkMethodAnnotations.hasCustomParameters();
    }

    @Override
    public Object[] getParameters() {
        CustomParametersDescriptor parameters = frameworkMethodAnnotations.getCustomParameters();
        ParametersProvider provider = instantiate(parameters.provider());
        provider.initialize(parameters.annotation());
        return provider.getParameters();
    }

    private ParametersProvider instantiate(Class<? extends ParametersProvider> providerClass) {
        try {
            return providerClass.newInstance();
        } catch (Exception e) {
            throw new RuntimeException("Your Provider class must have a public no-arg constructor!", e);
        }
    }

}

@@ -265,16 +265,55 @@
 tions;%0A%0A
+import java.lang.reflect.Constructor;%0A%0A
 class Pa
@@ -450,17 +450,67 @@
 ations;%0A
+    private final FrameworkMethod frameworkMethod;
 %0A
-
     Para
@@ -565,24 +565,70 @@
 rkMethod) %7B%0A
+        this.frameworkMethod=frameworkMethod;%0A
         fram
@@ -1264,46 +1264,827 @@
     
-try %7B%0A            return providerClass
+Constructor%3C?%3E%5B%5D constructors = providerClass.getConstructors();%0A        for (Constructor%3C?%3E constructor : constructors) %7B%0A            Class%3C?%3E%5B%5D parameterTypes = constructor.getParameterTypes();%0A            if(parameterTypes.length==1)%7B%0A                if(parameterTypes%5B0%5D == FrameworkMethod.class)%7B%0A                    try %7B%0A                        return (ParametersProvider) constructor.newInstance(frameworkMethod);%0A                    %7D catch (Exception e) %7B%0A                        throw new RuntimeException(%22init error%22, e);%0A                    %7D%0A                %7Delse%7B%0A                    throw new RuntimeException(%22init error,1-arg constructor parameter type must be FrameworkMethod!%22);%0A                %7D%0A            %7Delse %7B%0A                try %7B%0A                    return (ParametersProvider) constructor
 .new
@@ -2095,32 +2095,40 @@
 ance();%0A        
+     
+   
 %7D catch (Excepti
@@ -2127,32 +2127,40 @@
 (Exception e) %7B%0A
+        
             thro
@@ -2252,23 +2252,153 @@
 e);%0A        
-%7D
+        %7D%0A            %7D%0A        %7D%0A        throw new RuntimeException(%22Your Provider class must have a public no-arg constructor!%22);
 %0A    %7D%0A%0A%7D%0A

enhance ParametersProvider that can get FrameworkMethod