All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.cucumber.core.options.ObjectFactoryParser Maven / Gradle / Ivy

There is a newer version: 7.18.0
Show newest version
package io.cucumber.core.options;

import io.cucumber.core.backend.ObjectFactory;

public final class ObjectFactoryParser {

    private ObjectFactoryParser() {

    }

    @SuppressWarnings("unchecked")
    public static Class parseObjectFactory(String cucumberObjectFactory) {
        Class objectFactoryClass;
        try {
            objectFactoryClass = Class.forName(cucumberObjectFactory);
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException(
                String.format("Could not load object factory class for '%s'", cucumberObjectFactory), e);
        }
        if (!ObjectFactory.class.isAssignableFrom(objectFactoryClass)) {
            throw new IllegalArgumentException(String.format("Object factory class '%s' was not a subclass of '%s'",
                objectFactoryClass, ObjectFactory.class));
        }
        return (Class) objectFactoryClass;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy