Skip to content
/ javo Public

Java Value Object Definition Language (formerly known as PojoGen)

License

Notifications You must be signed in to change notification settings

ehenoma/javo

Repository files navigation

Javo

JDK Latest

Javo (Java Value Objects) is a tool for quick and easy creation of value objects and beans in Java. An important goal is to keep the quality and safety of the created classes high. For example, for objects that should be immutable, defensive copies are used in the mutator and accessors as needed to ensure this immutability.

The software was fomerly known as Pojogen.


Struct Blueprints

The framework has its own language to create so-called struct blueprints. This is case-sensitive, includes generic wildcards and allows attributes to be written as in UML. Struct blueprints are used to specify the structure for a value object or Java Bean, which can then be parsed by the framework and converted into a valid Java source code.

The following source text shows how a valid structure blueprint can be written.

struct Foo {
  bar: Bar   // Single Bar attribute.
  baz: [Baz] // Array of Baz objects
  qux: <Qux> // Collection of Qux objects.
}

For a detailed introduction, read the specification.


The Generator

The generator module does the actual job of converting from a blueprint to valid Java source code. It has a simple interface and is very easily expandable internally. Configuration options are of course also given, whereby these come either in the form of flags or properties.

The following text shows how common BuildTools can be used to add the generator modules to your dependencies.

Maven
<dependency>
  <groupId>io.github.merlinosayimwen.javo</groupId>
  <artifactId>javo-generator</artifactId>
  <version>1.0</version>
</dependency>
Gradle
compile 'io.github.merlinosayimwen.javo:javo-generator:1.0'
Ivy
<dependency org="io.github.merlinosayimwen.javo" name="javo-generator" rev="1.0"/>

The following example illustrates how the generator can be used to convert an already parsed blueprint into a Java class.

Logger logger = Logger.getLogger("Pojo Example");
logger.setLevel(Level.ALL);

PojoGenerator generator = JavoGeneratorFactory.create().getInstance();
Struct parsed = // Your parsed struct.

String generatedCode = generator.generate(parserd);
logger.fine(generatedCode);

About

Java Value Object Definition Language (formerly known as PojoGen)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages