Example usage for javafx.util BuilderFactory getBuilder

List of usage examples for javafx.util BuilderFactory getBuilder

Introduction

In this page you can find the example usage for javafx.util BuilderFactory getBuilder.

Prototype

public Builder<?> getBuilder(Class<?> type);

Source Link

Document

Returns a builder suitable for constructing instances of the given type.

Usage

From source file:io.github.moosbusch.permagon.configuration.builder.spi.AbstractPermagonBuilder.java

@Override
public Object build() {
    Object result;/*from ww w  .  ja v a2s . c  o  m*/
    Class<?> thype = getType();
    BuilderFactory buylderFactory = getBuilderFactory();
    PermagonApplicationContext applicationCtx = getApplicationContext();
    Map<Class<?>, Converter> converterz = getConverters();
    Builder<?> builder = buylderFactory.getBuilder(thype);

    if (builder != null) {
        result = builder.build();
        applicationCtx.getBeanFactory().autowireBean(result);
    } else {
        result = applicationCtx.createBean(thype);
    }

    converterz.entrySet().stream().forEach((converterEntry) -> {
        ConvertUtils.register(converterEntry.getValue(), converterEntry.getKey());
    });

    if (result instanceof Pane) {
        Pane resultPane = (Pane) result;
        buildPane(resultPane);

    } else if (result instanceof ScrollPane) {
        ScrollPane resultPane = (ScrollPane) result;
        buildScrollPane(resultPane);
    } else if (result instanceof SplitPane) {
        SplitPane resultPane = (SplitPane) result;
        buildSplitPane(resultPane);
    } else if (result instanceof TabPane) {
        TabPane resultPane = (TabPane) result;
        buildTabPane(resultPane);
    } else if (result instanceof Tab) {
        Tab resultPane = (Tab) result;
        buildTab(resultPane);
    } else if (result instanceof ButtonBar) {
        ButtonBar resultPane = (ButtonBar) result;
        buildButtonBar(resultPane);
    } else if (result instanceof Accordion) {
        Accordion resultPane = (Accordion) result;
        buildAccordion(resultPane);
    } else if (result instanceof TitledPane) {
        TitledPane resultPane = (TitledPane) result;
        buildTitledPane(resultPane);
    } else if (result instanceof ToolBar) {
        ToolBar resultPane = (ToolBar) result;
        buildToolBar(resultPane);
    } else if (result instanceof MenuBar) {
        MenuBar resultPane = (MenuBar) result;
        buildMenuBar(resultPane);
    }

    try {
        BeanUtils.populate(result, this);
    } catch (IllegalAccessException | InvocationTargetException ex) {
        Logger.getLogger(AbstractPermagonBuilder.class.getName()).log(Level.SEVERE, null, ex);
    }

    return result;
}