public static ObjectFactory loadObjectFactory(ClassFinder classFinder, String objectFactoryClassName) {
        ObjectFactory objectFactory;
        try {
            Reflections reflections = new Reflections(classFinder);

            if (objectFactoryClassName != null) {
                Class<ObjectFactory> objectFactoryClass = (Class<ObjectFactory>) classFinder.loadClass(objectFactoryClassName);
                objectFactory = reflections.newInstance(new Class[0], new Object[0], objectFactoryClass);
            } else {
                List<URI> packages = asList(URI.create("classpath:cucumber/runtime"));
                objectFactory = reflections.instantiateExactlyOneSubclass(ObjectFactory.class, packages, new Class[0], new Object[0], null);
            }
        } catch (TooManyInstancesException e) {
            log.warn(e.getMessage());
            log.warn(getMultipleObjectFactoryLogMessage());
            objectFactory = new DefaultJavaObjectFactory();
        } catch (NoInstancesException e) {
            objectFactory = new DefaultJavaObjectFactory();
        } catch (ClassNotFoundException e) {
            throw new CucumberException("Couldn't instantiate custom ObjectFactory", e);
        }
        return objectFactory;
    }
public static ObjectFactory loadObjectFactory ( ClassFinder classFinder , String objectFactoryClassName ) { ObjectFactory objectFactory ; try { Reflections reflections = new Reflections ( classFinder ) ; if ( objectFactoryClassName != null ) { Class < ObjectFactory > objectFactoryClass = ( Class < ObjectFactory > ) classFinder . loadClass ( objectFactoryClassName ) ; objectFactory = reflections . newInstance ( new Class [ 0 ] , new Object [ 0 ] , objectFactoryClass ) ; } else { List < URI > packages = asList ( URI . create ( "classpath:cucumber/runtime" ) ) ; objectFactory = reflections . instantiateExactlyOneSubclass ( ObjectFactory . class , packages , new Class [ 0 ] , new Object [ 0 ] , null ) ; } } catch ( TooManyInstancesException e ) { log . warn ( e . getMessage ( ) ) ; log . warn ( getMultipleObjectFactoryLogMessage ( ) ) ; objectFactory = new DefaultJavaObjectFactory ( ) ; } catch ( NoInstancesException e ) { objectFactory = new DefaultJavaObjectFactory ( ) ; } catch ( ClassNotFoundException e ) { throw new CucumberException ( "Couldn't instantiate custom ObjectFactory" , e ) ; } return objectFactory ; }
Loads an instance of {@link ObjectFactory}. The class name can be explicit, or it can be null.
When it's null, the implementation is searched for in the <pre>cucumber.runtime</pre> packahe.

@param classFinder            where to load classes from
@param objectFactoryClassName specific class name of {@link ObjectFactory} implementation. May be null.
@return an instance of {@link ObjectFactory}