Apache Velocity is an open source, Java-based template engine and code generator that converts templates into source code. Because it is implemented in Java, it is capable of interpreting varied templates and generating code for any language (web, service, SQL, scripts, etc.), although it seems to be oriented mostly toward web development.
Source: How to generate code with Apache Velocity | Opensource.com