Search in sources :

Example 1 with Type

use of com.spectralogic.ds3autogen.go.models.type.Type in project ds3_autogen by SpectraLogic.

the class GoCodeGenerator method generateType.

/**
     * Generates the response model represented by the specified {@link Ds3Type}
     */
private void generateType(final Ds3Type ds3Type) throws IOException, TemplateException {
    final Template tmpl = getTypeTemplate(ds3Type);
    final TypeModelGenerator<?> generator = getTypeGenerator(ds3Type);
    final Type type = generator.generate(ds3Type);
    final Path path = destDir.resolve(BASE_PROJECT_PATH.resolve(Paths.get(COMMANDS_NAMESPACE.replace(".", "/") + "/" + uncapitalize(type.getName()) + ".go")));
    LOG.info("Getting OutputStream for file: {}", path.toString());
    try (final OutputStream outputStream = fileUtils.getOutputFile(path);
        final Writer writer = new OutputStreamWriter(outputStream)) {
        tmpl.process(type, writer);
    }
}
Also used : Path(java.nio.file.Path) Type(com.spectralogic.ds3autogen.go.models.type.Type) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) OutputStream(java.io.OutputStream) OutputStreamWriter(java.io.OutputStreamWriter) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer)

Aggregations

Ds3Type (com.spectralogic.ds3autogen.api.models.apispec.Ds3Type)1 Type (com.spectralogic.ds3autogen.go.models.type.Type)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 Path (java.nio.file.Path)1