
io.magentys.screens.ScreenFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cherry Show documentation
Show all versions of cherry Show documentation
A syntactical sugar project for BDD oriented tests
package io.magentys.screens;
import io.magentys.exceptions.ScreenException;
import io.magentys.screens.annotations.ScreenElement;
import java.lang.reflect.Field;
import java.util.*;
public abstract class ScreenFactory {
public T init(T screen) {
Field[] fields = screen.getClass().getFields();
for (Field field : fields) {
try {
instantiateAndRemember(screen, field);
} catch (IllegalAccessException e) {
throw new ScreenException("I wasn't able to instantiate your " + screen.getClass() + ". Issue is:\n" + e.getMessage());
}
}
return screen;
}
protected abstract void instantiateAndRemember(T screen, Field field) throws IllegalAccessException;
protected static boolean isElement(Field field) {
java.util.List> interfaces = Arrays.asList(field.getType().getInterfaces());
return interfaces.contains(ScreenElement.class);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy