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

com.github.invictum.panels.builder.RegularPanelBuilder Maven / Gradle / Ivy

The newest version!
package com.github.invictum.panels.builder;

import com.github.invictum.panels.AbstractPanel;
import com.github.invictum.panels.init.PanelInitUtil;
import com.github.invictum.panels.proxy.LazyPanelElementFactory;
import net.serenitybdd.core.pages.WebElementFacade;

import java.util.ArrayList;
import java.util.List;

public class RegularPanelBuilder extends PanelBuilder {

    public RegularPanelBuilder(Class panelClass) {
        super(panelClass);
    }

    @Override
    public T build() {
        getPage().activateIfJQueryRelated(locator());
        PanelInitUtil.applyGlobalInitStrategy(panelClass(), getPage());
        T panelInstance = assemblePanelWithReflection();
        panelInstance.initWith(getPage(), LazyPanelElementFactory.produce(getPage(), locator()));
        PanelInitUtil.invokeWhenInitializedMethods(panelInstance);
        return panelInstance;
    }

    @Override
    public List buildAll() {
        getPage().activateIfJQueryRelated(locator());
        List panels = getPage().findAll(locator());
        PanelInitUtil.applyGlobalInitStrategy(panelClass(), getPage());
        List panelList = new ArrayList<>();
        for (WebElementFacade element : panels) {
            T panel = assemblePanelWithReflection();
            panel.initWith(getPage(), element);
            PanelInitUtil.invokeWhenInitializedMethods(panel);
            panelList.add(panel);
        }
        return panelList;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy