auto
A collection of source code generators for Java.
A set of four Google-maintained Java code generators that eliminate repetitive boilerplate, automatically producing immutable value objects, factory classes, service-loader configs, and annotation processor utilities at compile time.
Auto is a collection of code generators for Java, maintained by Google. The idea behind it is that Java programs often require large amounts of repetitive boilerplate code, the kind that a developer has to write again and again for different classes, and that can contain subtle mistakes precisely because it is so tedious to write. Auto generates that code automatically so that developers can focus on the parts that actually matter.
The project is divided into four tools that each target a different type of repetitive Java code. AutoValue generates immutable value objects, which are classes whose only purpose is to hold data and compare equal when their data is the same. AutoFactory generates factory classes that follow a standard Java dependency-injection pattern called JSR-330. AutoService generates the configuration files that Java's ServiceLoader mechanism needs to discover plugins and extensions. The Common subproject provides shared utilities used by people writing their own annotation processors.
All four tools work through Java's annotation processor mechanism, meaning you add a small annotation to your code and the generator produces the boilerplate at compile time. The generated code behaves exactly as if you had written it by hand, but you never have to look at it or maintain it.
The repository is open source under the Apache 2.0 license and each subproject is available as a published library through Maven Central, the standard package registry for Java projects.
Where it fits
- Automatically generate equals, hashCode, and toString for Java data classes using AutoValue instead of writing them by hand
- Generate factory classes for dependency-injection patterns without writing the boilerplate with AutoFactory
- Register service-provider plugins for Java's ServiceLoader mechanism automatically using AutoService
- Use the Common utilities subproject as a foundation when writing your own Java annotation processors