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

de.factoryfx.factory.SubTreeCreator Maven / Gradle / Ivy

package de.factoryfx.factory;

import java.util.function.Function;

import de.factoryfx.data.Data;

/**
 * create subtree with liveobject to instantiate only part of the tree e.g for test or in the gui
 *
 * @param  create Live object
 * @param  visitor
 * @param  root
 * @param  sub root
 */
public class SubTreeCreator, S extends FactoryBase> {

    private final Function subRootFactoryProvider;

    public SubTreeCreator(Function subRootFactoryProvider) {
        this.subRootFactoryProvider = subRootFactoryProvider;
    }

    @SuppressWarnings("unchecked")
    public L create(Data data){
        //TODO add generic root to data?
        R rootFactory= (R) data.internal().getRoot();
        final R copy = rootFactory.internal().copyFromRoot();
        return subRootFactoryProvider.apply(copy).internalFactory().create();
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy