// Path: src/main/java/org/junit/internal/Classes.java
// public class Classes {
// 
//     /**
//      * Do not instantiate.
//      * @deprecated will be private soon.
//      */
//     @Deprecated
//     public Classes() {
//     }
// 
//     /**
//      * Returns Class.forName for {@code className} using the current thread's class loader.
//      * If the current thread does not have a class loader, falls back to the class loader for
//      * {@link Classes}.
//      *
//      * @param className Name of the class.
//      */
//     public static Class<?> getClass(String className) throws ClassNotFoundException {
//         return getClass(className, Classes.class);
//     }
// 
//     /**
//      * Returns Class.forName for {@code className} using the current thread's class loader.
//      * If the current thread does not have a class loader, falls back to the class loader for the
//      * passed-in class.
//      *
//      * @param className Name of the class.
//      * @param callingClass Class that is requesting a the class
//      * @since 4.13
//      */
//     public static Class<?> getClass(String className, Class<?> callingClass) throws ClassNotFoundException {
//         ClassLoader classLoader = currentThread().getContextClassLoader();
//         return Class.forName(className, true, classLoader == null ? callingClass.getClassLoader() : classLoader);
//     }
// }


import org.junit.internal.Classes;
import org.junit.runner.FilterFactory.FilterNotCreatedException;
import org.junit.runner.manipulation.Filter;

package org.junit.runner;


/**
 * Utility class whose methods create a {@link FilterFactory}.
 */
class FilterFactories {
    /**
     * Creates a {@link Filter}.
     *
     * A filter specification is of the form "package.of.FilterFactory=args-to-filter-factory" or
     * "package.of.FilterFactory".
     *
     * @param request the request that will be filtered
     * @param filterSpec the filter specification
     */
    public static Filter createFilterFromFilterSpec(Request request, String filterSpec)
            throws FilterFactory.FilterNotCreatedException {
        Description topLevelDescription = request.getRunner().getDescription();
        String[] tuple;

        if (filterSpec.contains("=")) {
            tuple = filterSpec.split("=", 2);
        } else {
            tuple = new String[]{ filterSpec, "" };
        }

        return createFilter(tuple[0], new FilterFactoryParams(topLevelDescription, tuple[1]));
    }

    /**
     * Creates a {@link Filter}.
     *
     * @param filterFactoryFqcn The fully qualified class name of the {@link FilterFactory}
     * @param params The arguments to the {@link FilterFactory}
     */
    public static Filter createFilter(String filterFactoryFqcn, FilterFactoryParams params)
            throws FilterFactory.FilterNotCreatedException {
        FilterFactory filterFactory = createFilterFactory(filterFactoryFqcn);

        return filterFactory.createFilter(params);
    }

    /**
     * Creates a {@link Filter}.
     *
     * @param filterFactoryClass The class of the {@link FilterFactory}
     * @param params             The arguments to the {@link FilterFactory}
     *
     */
    public static Filter createFilter(Class<? extends FilterFactory> filterFactoryClass, FilterFactoryParams params)
            throws FilterFactory.FilterNotCreatedException {
        FilterFactory filterFactory = createFilterFactory(filterFactoryClass);

        return filterFactory.createFilter(params);
    }

    static FilterFactory createFilterFactory(String filterFactoryFqcn) throws FilterNotCreatedException {
        Class<? extends FilterFactory> filterFactoryClass;

        try {

// Path: src/main/java/org/junit/internal/Classes.java
// public class Classes {
// 
//     /**
//      * Do not instantiate.
//      * @deprecated will be private soon.
//      */
//     @Deprecated
//     public Classes() {
//     }
// 
//     /**
//      * Returns Class.forName for {@code className} using the current thread's class loader.
//      * If the current thread does not have a class loader, falls back to the class loader for
//      * {@link Classes}.
//      *
//      * @param className Name of the class.
//      */
//     public static Class<?> getClass(String className) throws ClassNotFoundException {
//         return getClass(className, Classes.class);
//     }
// 
//     /**
//      * Returns Class.forName for {@code className} using the current thread's class loader.
//      * If the current thread does not have a class loader, falls back to the class loader for the
//      * passed-in class.
//      *
//      * @param className Name of the class.
//      * @param callingClass Class that is requesting a the class
//      * @since 4.13
//      */
//     public static Class<?> getClass(String className, Class<?> callingClass) throws ClassNotFoundException {
//         ClassLoader classLoader = currentThread().getContextClassLoader();
//         return Class.forName(className, true, classLoader == null ? callingClass.getClassLoader() : classLoader);
//     }
// }


// Path: src/main/java/org/junit/runner/FilterFactories.java
import org.junit.internal.Classes;
import org.junit.runner.FilterFactory.FilterNotCreatedException;
import org.junit.runner.manipulation.Filter;

package org.junit.runner;


/**
 * Utility class whose methods create a {@link FilterFactory}.
 */
class FilterFactories {
    /**
     * Creates a {@link Filter}.
     *
     * A filter specification is of the form "package.of.FilterFactory=args-to-filter-factory" or
     * "package.of.FilterFactory".
     *
     * @param request the request that will be filtered
     * @param filterSpec the filter specification
     */
    public static Filter createFilterFromFilterSpec(Request request, String filterSpec)
            throws FilterFactory.FilterNotCreatedException {
        Description topLevelDescription = request.getRunner().getDescription();
        String[] tuple;

        if (filterSpec.contains("=")) {
            tuple = filterSpec.split("=", 2);
        } else {
            tuple = new String[]{ filterSpec, "" };
        }

        return createFilter(tuple[0], new FilterFactoryParams(topLevelDescription, tuple[1]));
    }

    /**
     * Creates a {@link Filter}.
     *
     * @param filterFactoryFqcn The fully qualified class name of the {@link FilterFactory}
     * @param params The arguments to the {@link FilterFactory}
     */
    public static Filter createFilter(String filterFactoryFqcn, FilterFactoryParams params)
            throws FilterFactory.FilterNotCreatedException {
        FilterFactory filterFactory = createFilterFactory(filterFactoryFqcn);

        return filterFactory.createFilter(params);
    }

    /**
     * Creates a {@link Filter}.
     *
     * @param filterFactoryClass The class of the {@link FilterFactory}
     * @param params             The arguments to the {@link FilterFactory}
     *
     */
    public static Filter createFilter(Class<? extends FilterFactory> filterFactoryClass, FilterFactoryParams params)
            throws FilterFactory.FilterNotCreatedException {
        FilterFactory filterFactory = createFilterFactory(filterFactoryClass);

        return filterFactory.createFilter(params);
    }

    static FilterFactory createFilterFactory(String filterFactoryFqcn) throws FilterNotCreatedException {
        Class<? extends FilterFactory> filterFactoryClass;

        try {

            filterFactoryClass = Classes.getClass(filterFactoryFqcn).asSubclass(FilterFactory.class);
