DOC
- the Document type to useT
- the codegen type to make (Class, Interface or Enum)public interface Translator<DOC extends Document & HasMainInterface,T> extends Supplier<File>
Document
into something else. This
interface is implemented to generate more files from the same database
structure.Document
Modifier and Type | Interface and Description |
---|---|
static interface |
Translator.Builder<T>
A general interface for all builder implementations used by this
Translator . |
static class |
Translator.Phase
The make process is divided into three phases;
Translator.Phase.PRE_MAKE ,
Translator.Phase.MAKE and Translator.Phase.POST_MAKE , as specified by this enum. |
Modifier and Type | Method and Description |
---|---|
default Optional<Column> |
column()
Return this node or any ancestral node that is a
Column . |
default Stream<? extends Column> |
columns()
Returns a stream over all enabled columns in the node tree.
|
default Optional<Dbms> |
dbms()
Return this node or any ancestral node that is a
Dbms . |
default Stream<? extends ForeignKey> |
foreignKeys()
Returns a stream over all enabled foreign keys in the node tree.
|
default Meta<File,String> |
generate()
Generates code for the
Document contained in this
Translator . |
default HasAlias |
getAliasDocument()
The document being translated wrapped in a
HasAlias . |
Generator |
getCodeGenerator()
Returns the CodeGen
Generator used by this Translator . |
DOC |
getDocument()
The document being translated.
|
default <E extends Document> |
getDocument(Class<E> clazz)
Returns this node or one of the ancestor nodes if it matches the
specified
Class . |
default Stream<? extends Index> |
indexes()
Returns a stream over all enabled indexes in the node tree.
|
boolean |
isInGeneratedPackage()
Returns
true if the file generated by this Translator
should be located in a .generated. package. |
Stream<BiConsumer<File,Translator.Builder<T>>> |
listeners()
Returns a
Stream of the listeners currently part of the make
process of this Translator . |
void |
onMake(BiConsumer<File,Translator.Builder<T>> action)
Append an additional action that should be executed as part of the make
process of this translator.
|
default void |
onMake(Consumer<Translator.Builder<T>> action)
Append an additional action that should be executed as part of the make
process of this translator.
|
default Stream<? extends PrimaryKeyColumn> |
primaryKeyColumns()
Returns a stream over all enabled primary key columns in the node tree.
|
default Optional<Project> |
project()
Return this node or any ancestral node that is a
Project . |
default Optional<Schema> |
schema()
Return this node or any ancestral node that is a
Schema . |
default Optional<Table> |
table()
Return this node or any ancestral node that is a
Table . |
default String |
toCode()
Generates and returns the code translated from the contained
Document by this Translator . |
default Optional<Project> project()
Project
. If no
such node exists, an IllegalStateException
is thrown.default Optional<Dbms> dbms()
Dbms
. If no such
node exists, an IllegalStateException
is thrown.default Optional<Schema> schema()
Schema
. If no
such node exists, an IllegalStateException
is thrown.default Optional<Table> table()
Table
. If no
such node exists, an IllegalStateException
is thrown.default Optional<Column> column()
Column
. If no
such node exists, an IllegalStateException
is thrown.default Stream<? extends Column> columns()
Column
,
HasEnabled.isEnabled()
default Stream<? extends Index> indexes()
Index
,
HasEnabled.isEnabled()
default Stream<? extends ForeignKey> foreignKeys()
ForeignKey
,
HasEnabled.isEnabled()
default Stream<? extends PrimaryKeyColumn> primaryKeyColumns()
PrimaryKeyColumn
,
HasEnabled.isEnabled()
DOC getDocument()
default <E extends Document> Optional<E> getDocument(Class<E> clazz)
Class
. If no such node exists, an
IllegalStateException
is thrown.E
- the type of the class to matchclazz
- the class to matchdefault HasAlias getAliasDocument()
HasAlias
.default Meta<File,String> generate()
Document
contained in this
Translator
.default String toCode()
Document
by this Translator
.boolean isInGeneratedPackage()
true
if the file generated by this Translator
should be located in a .generated.
package. Files located in
such a package will be overwritten each time the generator runs.true
if located in .generated.
, else false
Generator getCodeGenerator()
Generator
used by this Translator
.
This can be used to add dependencies to the runtime or to install new
views.Generator
useddefault void onMake(Consumer<Translator.Builder<T>> action)
If the action requires additional Import
statements to
be added to the generated file, the onMake(BiConsumer)
method
should be used instead.
action
- the action to performonMake(BiConsumer)
void onMake(BiConsumer<File,Translator.Builder<T>> action)
This method allows the action to affect both the Translator.Builder
and the
file where the class or interface will be located. This should be used
if the specified action require additional Import
statements to
be added to the file.
action
- the action to performonMake(BiConsumer)
Stream<BiConsumer<File,Translator.Builder<T>>> listeners()
Stream
of the listeners currently part of the make
process of this Translator
.Stream
of all listenersCopyright © 2016 Speedment, Inc.. All rights reserved.