-
- All Known Implementing Classes:
StandardGenerator,StandardJavaGenerator
public interface GeneratorA hook to the generator that can be passed to various stages in the pipeline. Contains multiple methods for generating model-to-model or model-to-text.- Since:
- 2.0
- Author:
- Emil Forslund
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static Generatorcreate(DependencyManager mgr, TransformFactory factory)Creates and returns a new Generator.static GeneratorforJava()Returns an implementation of this interface that uses the default implementation used to generate Java code.DependencyManagergetDependencyMgr()Returns theDependencyManagercurrently being used.RenderStackgetRenderStack()Returns the current rendering stack.<A,B>
Stream<Meta<A,B>>metaOn(A from, Class<B> to)Renders the specified model into a stream of code models.default <A,B>
Stream<Meta<A,B>>metaOn(A from, Class<B> to, Class<? extends Transform<A,B>> transform)Renders the specified model into a stream of code models.default <A> Stream<Meta<A,String>>metaOn(Collection<A> models)Renders all the specified models into a stream of code models.default <A,B>
Stream<Meta<A,B>>metaOn(Collection<A> models, Class<B> to)Renders all the specified models into a stream of code models.default <A,B>
Stream<Meta<A,B>>metaOn(Collection<A> models, Class<B> to, Class<? extends Transform<A,B>> transform)Renders all the specified models into a stream of code models.default <M> Stream<Meta<M,String>>metaOn(M model)Renders the specified model into a stream of code models.default Optional<String>on(Object model)Locates theTransformthat corresponds to the specified model and uses it to generate aString.default <M> Stream<String>onEach(Collection<M> models)Renders all the specified models into a stream of strings.<A,B>
Optional<Meta<A,B>>transform(Transform<A,B> transform, A model, TransformFactory factory)Transforms the specified model using the specifiedTransformfrom the specifiedTransformFactory.
-
-
-
Method Detail
-
getDependencyMgr
DependencyManager getDependencyMgr()
Returns theDependencyManagercurrently being used.- Returns:
- the dependency manager
- See Also:
DependencyManager
-
getRenderStack
RenderStack getRenderStack()
Returns the current rendering stack. The top element will be the one most recent rendered and the bottom one will be the element that was first passed to the generator. Elements are removed from the stack once they have finished rendering.If an element needs to access its parent, it can call this method and peek on the second element from the top.
- Returns:
- the current rendering stack
- See Also:
RenderStack
-
metaOn
<A,B> Stream<Meta<A,B>> metaOn(A from, Class<B> to)
Renders the specified model into a stream of code models. This is used internally to provide the other interface methods.- Type Parameters:
A- the input typeB- the expected output type- Parameters:
from- the model to generateto- the model type to transform to- Returns:
- a stream of meta objects
- See Also:
Meta
-
metaOn
default <A,B> Stream<Meta<A,B>> metaOn(A from, Class<B> to, Class<? extends Transform<A,B>> transform)
Renders the specified model into a stream of code models. This is used internally to provide the other interface methods.If the specified transform is not installed, an empty stream will be returned.
- Type Parameters:
A- the input typeB- the expected output type- Parameters:
from- the model to generateto- the model type to transform totransform- the specified transform to use- Returns:
- a stream of meta objects
- See Also:
Meta
-
metaOn
default <M> Stream<Meta<M,String>> metaOn(M model)
Renders the specified model into a stream of code models. This is used internally to provide the other interface methods.- Type Parameters:
M- the model type- Parameters:
model- the model to generate- Returns:
- a stream of meta objects
- See Also:
Meta
-
metaOn
default <A> Stream<Meta<A,String>> metaOn(Collection<A> models)
Renders all the specified models into a stream of code models. This is used internally to provide the other interface methods.- Type Parameters:
A- the input type- Parameters:
models- the models to generate- Returns:
- a stream of meta objects
- See Also:
Meta
-
metaOn
default <A,B> Stream<Meta<A,B>> metaOn(Collection<A> models, Class<B> to)
Renders all the specified models into a stream of code models. This is used internally to provide the other interface methods.- Type Parameters:
A- the input typeB- the expected output type- Parameters:
models- the models to generateto- the expected result type- Returns:
- a stream of meta objects
- See Also:
Meta
-
metaOn
default <A,B> Stream<Meta<A,B>> metaOn(Collection<A> models, Class<B> to, Class<? extends Transform<A,B>> transform)
Renders all the specified models into a stream of code models. This is used internally to provide the other interface methods. This will only return results from the specified transform.If the specified transform is not installed, an empty stream will be returned.
- Type Parameters:
A- the input typeB- the expected output type- Parameters:
models- the models to generateto- the expected result typetransform- the specific transform to use- Returns:
- a stream of meta objects
- See Also:
Meta
-
on
default Optional<String> on(Object model)
Locates theTransformthat corresponds to the specified model and uses it to generate aString. If no view is associated with the model type, an emptyOptionalwill be returned.- Parameters:
model- the model- Returns:
- the generated text if any
-
onEach
default <M> Stream<String> onEach(Collection<M> models)
Renders all the specified models into a stream of strings.- Type Parameters:
M- the model type- Parameters:
models- the models to generate- Returns:
- a stream of meta objects
-
transform
<A,B> Optional<Meta<A,B>> transform(Transform<A,B> transform, A model, TransformFactory factory)
Transforms the specified model using the specifiedTransformfrom the specifiedTransformFactory.- Type Parameters:
A- the input typeB- the expected output type- Parameters:
transform- the transform to usemodel- the inputed modelfactory- the factory used when instantiating the transform- Returns:
- the meta object if successful, else empty
- See Also:
Transform,TransformFactory
-
forJava
static Generator forJava()
Returns an implementation of this interface that uses the default implementation used to generate Java code.- Returns:
- the default generator for Java
-
create
static Generator create(DependencyManager mgr, TransformFactory factory)
Creates and returns a new Generator.- Parameters:
mgr- the dependency manager to usefactory- the factory to use- Returns:
- a new Generator
- Throws:
NullPointerException- if any of the provided parameters arenull
-
-