@Test public void testGenerate() throws Exception { GenerationContext context = new GenerationContextImpl(new MyModel( "hoge"), new File("file"), getClass().getSimpleName() + "_Generate.ftl", "UTF-8", false); generator.generate(context); assertEquals("hoge", generator.getResult()); }
public void generate(GenerationContext context) { boolean exists = exists(context.getFile()); if (!context.isOverwrite() && exists) { return; } File dir = context.getFile().getParentFile(); if (dir != null) { mkdirs(dir); } Writer writer = openWriter(context); try { Template template = getTemplate(context.getTemplateName()); process(template, context.getModel(), writer); } finally { CloseableUtil.close(writer); } if (writer instanceof DeleteEmptyFileWriter) { if (((DeleteEmptyFileWriter) writer).isDeleted()) { return; } } if (exists) { logger.log("DS2JDBCGen0009", new Object[] { context.getFile() .getPath() }); } else { logger.log("DS2JDBCGen0002", new Object[] { context.getFile() .getPath() }); } }
GeneratorImpl implements Generator { public void generate(GenerationContext context) { boolean exists = exists(context.getFile()); if (!context.isOverwrite() && exists) { return; } File dir = context.getFile().getParentFile(); if (dir != null) { mkdirs(dir); } Writer writer = openWriter(context); try { Template template = getTemplate(context.getTemplateName()); process(template, context.getModel(), writer); } finally { CloseableUtil.close(writer); } if (writer instanceof DeleteEmptyFileWriter) { if (((DeleteEmptyFileWriter) writer).isDeleted()) { return; } } if (exists) { logger.log("DS2JDBCGen0009", new Object[] { context.getFile() .getPath() }); } else { logger.log("DS2JDBCGen0002", new Object[] { context.getFile() .getPath() }); } } }
GeneratorImpl implements Generator { public void generate(GenerationContext context) { boolean exists = exists(context.getFile()); if (!context.isOverwrite() && exists) { return; } File dir = context.getFile().getParentFile(); if (dir != null) { mkdirs(dir); } Writer writer = openWriter(context); try { Template template = getTemplate(context.getTemplateName()); process(template, context.getModel(), writer); } finally { CloseableUtil.close(writer); } if (writer instanceof DeleteEmptyFileWriter) { if (((DeleteEmptyFileWriter) writer).isDeleted()) { return; } } if (exists) { logger.log("DS2JDBCGen0009", new Object[] { context.getFile() .getPath() }); } else { logger.log("DS2JDBCGen0002", new Object[] { context.getFile() .getPath() }); } } GeneratorImpl(Configuration configuration);  GeneratorImpl(String templateFileEncoding,
            File templateFilePrimaryDir); }
GeneratorImpl implements Generator { public void generate(GenerationContext context) { boolean exists = exists(context.getFile()); if (!context.isOverwrite() && exists) { return; } File dir = context.getFile().getParentFile(); if (dir != null) { mkdirs(dir); } Writer writer = openWriter(context); try { Template template = getTemplate(context.getTemplateName()); process(template, context.getModel(), writer); } finally { CloseableUtil.close(writer); } if (writer instanceof DeleteEmptyFileWriter) { if (((DeleteEmptyFileWriter) writer).isDeleted()) { return; } } if (exists) { logger.log("DS2JDBCGen0009", new Object[] { context.getFile() .getPath() }); } else { logger.log("DS2JDBCGen0002", new Object[] { context.getFile() .getPath() }); } } GeneratorImpl(Configuration configuration);  GeneratorImpl(String templateFileEncoding,
            File templateFilePrimaryDir); void generate(GenerationContext context); }
GeneratorImpl implements Generator { public void generate(GenerationContext context) { boolean exists = exists(context.getFile()); if (!context.isOverwrite() && exists) { return; } File dir = context.getFile().getParentFile(); if (dir != null) { mkdirs(dir); } Writer writer = openWriter(context); try { Template template = getTemplate(context.getTemplateName()); process(template, context.getModel(), writer); } finally { CloseableUtil.close(writer); } if (writer instanceof DeleteEmptyFileWriter) { if (((DeleteEmptyFileWriter) writer).isDeleted()) { return; } } if (exists) { logger.log("DS2JDBCGen0009", new Object[] { context.getFile() .getPath() }); } else { logger.log("DS2JDBCGen0002", new Object[] { context.getFile() .getPath() }); } } GeneratorImpl(Configuration configuration);  GeneratorImpl(String templateFileEncoding,
            File templateFilePrimaryDir); void generate(GenerationContext context);  }