@Override
        public T build() {
            final T model = mainModelConstructor.apply(name);

            if (isInGeneratedPackage()) {
                model.add(generated());
            }

            for (Phase phase : Phase.values()) {
                project().ifPresent(p -> act(phase, PROJECTS, model, p));
                dbms().ifPresent(d -> act(phase, ProjectUtil.DBMSES, model, d));
                schema().ifPresent(s -> act(phase, DbmsUtil.SCHEMAS, model, s));
                table().ifPresent(t -> act(phase, SchemaUtil.TABLES, model, t));

                MapStream.of(map.get(phase))
                    .flatMapValue(List::stream)
                    .forEachOrdered((key, actor) -> table()
                        .ifPresent(table -> MapStream.of(table.getData())
                            .filterKey(key::equals)

                            // Filter out elements that map to a list and flat
                            // map the stream so that every value in the list
                            // becomes an element of the stream.
                            .filterValue(List.class::isInstance)
                            .mapValue(AbstractJavaClassTranslator::castToListOfMap)
                            .flatMapValue(List::stream)

                            // The foreignKeys-property is special in that only
                            // keys that reference enabled and existing table
                            // and columns are to be included.
                            .filter((k, v) -> {
                                if (TableUtil.FOREIGN_KEYS.equals(k)) {
                                    return ForeignKey.create(table, v)
                                        .foreignKeyColumns()
                                        .map(ForeignKeyColumn::findColumn)
                                        .allMatch(c ->
                                            c.filter(Column::isEnabled)
                                                .map(Column::getParentOrThrow)
                                                .filter(Table::isEnabled)
                                                .isPresent()
                                        );

                                    // Indexes, PrimaryKeyColumns and Columns should
                                    // be handled as usual.
                                } else return true;
                            })

                            // We are now done with the keys. Use the values of
                            // the stream to produce an ordinary stream of base
                            // documents.
                            .values()
                            .map(data -> new BaseDocument(table, data))

                            // All the documents that are enabled should be
                            // passed to the actor.
                            .filter(HasEnabled::test)
                            .forEachOrdered(c -> actor.accept(model, c))
                        )
                    );

                if (Table.class.equals(getDocument().mainInterface())) {
                    schema().ifPresent(schema -> schema.tables()
                        .filter(HasEnabled::test)
                        .flatMap(Table::foreignKeys)
                        .filter(HasEnabled::test)
                        .filter(fk -> fk.foreignKeyColumns()
                            .filter(fkc -> fkc.getForeignTableName().equals(getDocument().getId()))
                            .filter(HasEnabled::test)
                            .anyMatch(fkc -> fkc.findForeignColumn().map(HasEnabled::test).orElse(false))
                        ).forEachOrdered(fk
                            -> foreignKeyReferencesThisTableConsumers.get(phase).forEach(
                            c -> c.accept(model, fk)
                            )
                        )
                    );
                }

                // Traverse downwards, Fix #224
                namedChildren(document)
                    .forEach(e -> processDocument(model, phase, e.getKey(), e.getValue()));

            }
            return model;
        }
This method is executed after the file has been created but before it is
returned to the code generator.

@param file the file to operate on
generator-parent/generator-translator/src/main/java/com/speedment/generator/translator/AbstractJavaClassTranslator.java