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

net.serenitybdd.screenplay.questions.UIStateReaderWithNameBuilder Maven / Gradle / Ivy

There is a newer version: 4.2.8
Show newest version
package net.serenitybdd.screenplay.questions;

import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.targets.Target;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Deprecated
public class UIStateReaderWithNameBuilder {
    protected final Target target;
    protected final Class type;

    public UIStateReaderWithNameBuilder(Target target, Class type) {
        this.target = target;
        this.type = type;
    }

    public PrimedUIStateReaderWithNameBuilder named(String name) {
        return new PrimedUIStateReaderWithNameBuilder(target, type, name);
    }

    public static class PrimedUIStateReaderWithNameBuilder extends UIStateReaderWithNameBuilder {

        private final String name;

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

        public PrimedUIStateReaderWithNameBuilder(Target target, Class type, String name) {
            super(target, type);
            this.name = name;
        }

        public  T viewedBy(Actor actor) {
            try {
                return (T) type.getConstructor(Target.class, Actor.class, String.class).newInstance(target, actor, name);
            } catch (Exception e) {
                logger.error("Failed to instantiate UIStateReader of type " + type, e);
                throw new IllegalStateException("Failed to instantiate UIStateReader of type " + type, e);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy