Class FactoryTreeBuilder<L,R extends FactoryBase<L,R>,S>
- java.lang.Object
-
- io.github.factoryfx.factory.builder.FactoryTreeBuilder<L,R,S>
-
- Type Parameters:
R- root factory
public class FactoryTreeBuilder<L,R extends FactoryBase<L,R>,S> extends java.lang.Objectutility class to build a factory hierarchy(dependency tree) see RichClientBuilder for an example It's called tree but really is a DAG (directed acyclic graph). It' called tree to emphasize the main limitation: no cycles.
-
-
Constructor Summary
Constructors Constructor Description FactoryTreeBuilder(java.lang.Class<R> rootClass)FactoryTreeBuilder(java.lang.Class<R> rootClass, java.util.function.Function<FactoryContext<R>,R> creator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <LO,F extends FactoryBase<LO,R>>
voidaddFactory(java.lang.Class<F> clazz, Scope scope)<F extends FactoryBase<?,R>>
voidaddFactory(java.lang.Class<F> clazz, Scope scope, java.util.function.Function<FactoryContext<R>,F> creator)<F extends FactoryBase<?,R>>
voidaddFactory(java.lang.Class<F> clazz, java.lang.String name, Scope scope, java.util.function.Function<FactoryContext<R>,F> creator)BranchSelector<R>branch()indented use is for testing to create branches and set mocks<LO,FO extends FactoryBase<LO,R>>
FObuildNewSubTree(java.lang.Class<FO> factoryClazz)the passed factoryClazz ist created new even if they is declared as Singleton<LO,FO extends FactoryBase<LO,R>>
java.util.List<FO>buildSubTrees(java.lang.Class<FO> factoryClazz)RbuildTree()create the complete factory tree that represent the app dependencies and validates the result
the tree is only created once per builder, multiple buildTree calls return the same resultRbuildTreeUnvalidated()create the complete factory tree that represent the app dependenciesvoidfillFromExistingFactoryTree(R root)ScopegetScope(java.lang.Class<?> factoryClazz)MicroserviceBuilder<L,R,S>microservice()MicroserviceBuilder<L,R,S>microservice(SimpleObjectMapper simpleObjectMapper)MicroserviceBuilder<L,R,S>microservice(java.util.function.Consumer<R> mocker)set mocks for factories
-
-
-
Constructor Detail
-
FactoryTreeBuilder
public FactoryTreeBuilder(java.lang.Class<R> rootClass)
-
FactoryTreeBuilder
public FactoryTreeBuilder(java.lang.Class<R> rootClass, java.util.function.Function<FactoryContext<R>,R> creator)
-
-
Method Detail
-
addFactory
public <F extends FactoryBase<?,R>> void addFactory(java.lang.Class<F> clazz, Scope scope, java.util.function.Function<FactoryContext<R>,F> creator)
-
addFactory
public <F extends FactoryBase<?,R>> void addFactory(java.lang.Class<F> clazz, java.lang.String name, Scope scope, java.util.function.Function<FactoryContext<R>,F> creator)
-
addFactory
public <LO,F extends FactoryBase<LO,R>> void addFactory(java.lang.Class<F> clazz, Scope scope)
-
buildTree
public R buildTree()
create the complete factory tree that represent the app dependencies and validates the result
the tree is only created once per builder, multiple buildTree calls return the same result- Returns:
- dependency tree
-
buildTreeUnvalidated
public R buildTreeUnvalidated()
create the complete factory tree that represent the app dependencies- Returns:
- dependency tree
-
buildNewSubTree
public <LO,FO extends FactoryBase<LO,R>> FO buildNewSubTree(java.lang.Class<FO> factoryClazz)
the passed factoryClazz ist created new even if they is declared as Singleton- Type Parameters:
LO- liveobjectFO- factory result- Parameters:
factoryClazz- factory- Returns:
- factory
-
buildSubTrees
public <LO,FO extends FactoryBase<LO,R>> java.util.List<FO> buildSubTrees(java.lang.Class<FO> factoryClazz)
-
branch
public BranchSelector<R> branch()
indented use is for testing to create branches and set mocks- Returns:
- BranchSelector
-
getScope
public Scope getScope(java.lang.Class<?> factoryClazz)
-
fillFromExistingFactoryTree
public void fillFromExistingFactoryTree(R root)
-
microservice
public MicroserviceBuilder<L,R,S> microservice()
-
microservice
public MicroserviceBuilder<L,R,S> microservice(SimpleObjectMapper simpleObjectMapper)
-
microservice
public MicroserviceBuilder<L,R,S> microservice(java.util.function.Consumer<R> mocker)
set mocks for factories- Parameters:
mocker- mocker- Returns:
- MicroserviceBuilder
-
-