About VALJOGen
VALJOGen can be used to generate modern Java 7/8+ value classes from annotated Java interfaces.
FEATURES:
- Can generate value objects with auto-implemented getters and setters from your interfaces.
- Support for auto-implementing factory methods, constructors, Object.hashCode, Object.equals, Object.toString, Comparable.compareTo etc.
- Can insert jackson-annotations as needed for conversions to/from JSON.
- Support for auto-implementation of Serializable and Externalizable interfaces.
- Extremely customizable code output. You can change every aspect for the generated class and even add your own code using StringTemplate 4 based custom templates.
- Great support for immutable value objects, including final fields and immutable setters (with-style-methods) that return new instances for each change.
- Support for synchronized/unsynchronized mutable value objects.
- Full support for overriding custom base classes with both default and non-default base constructors, for overriding base class methods, implementing abstract properties etc.
- Support for guards (checks) against null arguments, custom getter/setter prefixes, injection of extra interfaces into implementation etc.
- The annotation processor runs on any standard Java developer tool running JDK1.8+. Should work nicely with IDE’s without plugins (as long as they offer the usual standard annotation processor support).
- Use standard Java API’s (no hacks or virtual “language extensions”) so less risk of problems when a new JDK or IDE is released compared to some alternatives.
- Outputs modern and nicely formatted Java 1.7+ source code as if written by hand - without reflection and without any overhead.
- Generated code has no runtime dependencies on VALJOGen!
- Sensible defaults and auto-detection makes tool work out-of-the-box with very little work.
One of the strong benefits of VALJOGen is extreme customization facilities. With all other tools I have run into limitations like: Can not add my own custom methods, can not subclass or add a base class constructor with X arguments, can not make class abstract or change the way hash codes are calculated etc.
With VALJOGen everything is possible. Many options can be configured easily by annotations and if that is not enough you can supply a custom string template where you can extend or modify EVERYTHING you want in the generated output.
1. MODULES
The VALJOGen project consist of the following modules:
- Annotations (all source-level, with no dependencies). It’s jar file is not normally used by 3rd party projects unless one want to compile code using the annotations without the annotation processor. For details refer to the JavaDoc Api.
- The annotation processor and related tests. It’s jar file embeds all annotations along with a few dependencies.
- Integration tests.
- Examples. Where to look for detailed examples of how to use some of the more powerful features of the annotation processor.
2. HOW TO USE VALJOGen IN YOUR PROJECTS:
The VALJOGen annotationprocessor may be used with any standard-complient JDK1.8+ based tool like javac, eclipse, maven etc. Refer to the getting started document for more information.
3. HOW TO EXTEND VALJOGen AND CONTRIBUTE YOUR CHANGES:
Contributors and contributions are welcome. Refer to the contribution guide.
4. KNOWN ISSUES:
- Sometimes javac will fail with “java.lang.IllegalStateException: endPosTable already set” - in particular if the output directory is not empty. I suspect this is an error in the JDK but I do not know. If it happens clean(!) to remove existing ouputs, rebuild and it should succed.
- Maven does not always detect correctly when to rebuild after changes in templates. Do a
"mvn clean"
if this happens.
- Generated code only get the correct method parameter names if you add the “-parameters” option to javac.
- Support for XML/JSON serialization should be easier.
- Generator does not account for bounded generic type arguments when deciding if something is serializable or comparable.
- Due to Eclipse bug 382590 VALJOGen can not generated correct code when subclassing a generic interface. Please vote for the bug in bugzilla to help get it fixed.
5. RELEVANT LITTERATURE ABOUT JAVA VALUE OBJECTS:
6. LICENSE
7. SUPPORT
8. CREDITS
VALJOGen is build on JDK 1.8+ and has benefitted from using the following excellent open-source libraries and tools:
The website uses the following great open-source libraries and tools:
VALJOGen development is supported by 41concepts a Danish software R&D and consulting company.