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

cucumber.runtime.java.needle.config.CreateInstanceByDefaultConstructor Maven / Gradle / Ivy

There is a newer version: 6.11.0
Show newest version
package cucumber.runtime.java.needle.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Instantiates new java object by default constructor
 */
public enum CreateInstanceByDefaultConstructor {
    /**
     * Singleton
     */
    INSTANCE;

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    public final  T apply(final Class type) {
        try {
            final T newInstance = type.getConstructor().newInstance();
            logger.debug("newInstance by DefaultConstructor: " + newInstance);
            return newInstance;
        } catch (final Exception e) {
            throw new IllegalStateException("Can not instantiate Instance by Default Constructor.", e);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy