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

net.thucydides.core.steps.EnclosingClass Maven / Gradle / Ivy

There is a newer version: 4.2.1
Show newest version
package net.thucydides.core.steps;

import net.thucydides.core.annotations.InvalidStepsFieldException;

public class EnclosingClass {

    private Class innerClass;

    public EnclosingClass(Class innerClass) {
        this.innerClass = innerClass;
    }

    public static EnclosingClass of(Class innerClass) {
        return new EnclosingClass(innerClass);
    }

    public Object newInstance() {
        try {
            return innerClass.getEnclosingClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new InvalidStepsFieldException("Please ensure that there is a default constructor for " + innerClass.getEnclosingClass());
        }
    }

    public Object[] asParameters() {
        return new Object[] { newInstance() };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy