Skip to content
Java Code Generation Framework
Branch: master
Clone or download
verhas Merge pull request #13 from Michael1993/equals-update
Added super calls to core Equals generator.
Latest commit 9907813 Jul 3, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Nov 6, 2018
images dependencies changed May 25, 2019
javageci-annotation builder first version May 23, 2019
javageci-api set generates random name for unnamed sets Jun 25, 2019
javageci-core Added super hashCode calls to objects method when appropriate. Jul 3, 2019
javageci-engine fix a bug in Repeated Jun 28, 2019
javageci-examples Modified Equals generator to have param 'useSuper'. Jul 3, 2019
javageci-jamal getAllMethodsSorted now returns really all methods Jun 26, 2019
javageci-tools Removed copy-paste code, moved exception to a more logical place. Jul 3, 2019
.gitignore initial code upload Oct 4, 2018
.travis.yml dist:xenial in travis file Apr 29, 2019 Moved unnecessary tutorial part from to Jun 24, 2019 documentation updated Jun 1, 2019 Create Nov 6, 2018 mnemonic can be made configurable using an option in the config builder Jun 24, 2019 delegator implements a builder May 23, 2019 documentation was updated May 31, 2019 analysis and cleanup of the code Oct 10, 2018 FAQ updated according to suggestions by Martin Grajcar Jun 2, 2019 some more selectgors were added Jun 3, 2019 reformatted Apr 14, 2019 Moved unnecessary tutorial part from to Jun 24, 2019 analysis and cleanup of the code Oct 10, 2018 documentation Oct 30, 2018 documentation Oct 30, 2018
LICENSE Create LICENSE Nov 6, 2018 logging documentation Jun 21, 2019 typos discovered by KI and fixed Apr 10, 2019 modules documentation first complete draft May 25, 2019 documentation Oct 30, 2018 Moved unnecessary tutorial part from to Jun 24, 2019 template handling of segments is documented Jun 1, 2019 1.1.1-SNAPSHOT release Jan 29, 2019 Repeated generator is configurable with a valuesSupplier Jun 21, 2019 Templated developed further Jun 13, 2019 Minor documentation adjustments. Added missing md file. Jun 23, 2019 Reverted bad change in Jun 25, 2019 documentation update Apr 15, 2019 Reverted bad change in Jun 25, 2019
diagrams.graffle documentation continued May 26, 2019
genpom.xml pom files are cooked to jam Mar 6, 2019
plugins.jim pom files are cooked to jam Mar 6, 2019
pom.jim pom files are cooked to jam Mar 6, 2019
pom.xml surefire version bumped up to 2.22.1 Jul 1, 2019
pom.xml.jam surefire version bumped up to 2.22.1 Jul 1, 2019 updated Jan 29, 2019 documentation Oct 9, 2018
version.jim source comparator can be defined May 9, 2019


Java Generate Code Inline

Java::Geci is a library for generating Java code. Code generation programs implemented using Java::Geci can be executed to generate new source code or modify existing Java source files. This way the programmer can use meta programming to express code in a shorter and more expressive way than it would be possible in pure Java.

The framework discovers the files that need generated code, provides easy to use API to generate code and takes care of writing the generated code into the source code. The code generating program should focus on the actual code structure it wants to generate.

When do you need Java::Geci?

There are several occasions when we need generated code. The simplest such scenarios are also supported by IDEs (Eclipse, NetBeans, IntelliJ). They can create setters, getters, constructors, equals() and hashCode() methods in different ways. There are two major problems with that solution.

  • One is that the code generation is manual, and in case the developer forgets to re-generate the code after an influencing change the code becomes outdated.

  • The other problem is that the code generation possibilities are not extendable. There is a limited set of code that the tools can generate and the developer cannot easily extend these possibilities.

Java::Geci eliminates these two problems. It has an execution mode to check if all code generation is up-to-date and this can be used as a unit test. If the developer forgot to update some of the generated code after the program effecting the generated code was changed, the test will fail. (As a matter of fact the test also updates the generated code, you only need to start the build phase again.)

Java::Geci also has an extremely simple API supporting code generators so it is extremely simple to create new code generators that are project specific. You do not even need to package your code generator classes. Just put them into some of the test packages and execute Java::Geci during the test phase of the build process.

Java::Geci already includes several readily available code generators. These are packaged with the core package and can generate

  • setter and getter
  • delegation methods (under development)
  • fluent API classes and interfaces
  • others will be under development

How to use Java::Geci

Include the Java::Geci modules that you want to use in your project. To do that with maven use the following dependencies:

    <!-- This is optional, you can use your own annotations or comment config -->

This documentation contains the latest development version. For release versions you can use see the latest non-SNAPSHOT version in the release history documentation.

There are other modules, but you do not need to declare dependency on them as the engine module has transitive dependency and thus maven automatically will use them. Since Java::Geci works during test execution the dependencies have test scope. The exception is the annotation module. This module defines an annotation that can be used to configure the code generation during test time. Because of that the retention of this module is run-time. Although the annotation is not used in production but it remains in the byte code and thus is has to be the default maven scope.

If for any reason production dependency must not include Java::Geci you can configure some of the generators using comments or you can use your own annotation interfaces that you can define inside your project. Simply copy the and to your project into any of your packages and Java::Geci will recognize that they are to configure a generator.

If you look at the test code in the test module you can see that this is a proof of concept demonstration sample code:

package javax0.geci.tests.accessor;

import javax0.geci.accessor.Accessor;
import javax0.geci.engine.Geci;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static javax0.geci.api.Source.maven;

public class TestAccessor {

    public void testAccessor() throws Exception {
        Assertions.assertFalse(new Geci().source(maven()

The test runs during the build process and it generates files if that is needed. If files were generated it means that the code was not up to date and a new compilation has to be done. In this case the will be invoked and you have to start the build process again. Second time the code generation will recognize that the code it could generate is already there and the process will not fail.

For further information visit the following documentations

You can’t perform that action at this time.