Java annotation processor to create immutable objects and builders, for records too. Sweep boilerplate code under the rug!
Java annotation processor to create immutable objects and builders, for records too. Sweep boilerplate code under the rug!
Full documentation at immutables.org
@Value.Builder
record Person(String name, int age, String email) {}
// Use the generated builder
Person person = new PersonBuilder()
.name("Alice")
.age(30)
.email("[email protected]")
.build();
More fancy example having copy-with methods generated, and style withUnaryOperator="with*"
@Value.Builder
record Person(String name, int age) implements WithPerson {
// Extend the generated PersonBuilder
static class Builder extends PersonBuilder {}
}
// Use your custom builder
var person = new Person.Builder()
.name("Bob")
.age(18)
.build();
person = person.withName("Bobby!")
.withAge(age -> age + 3);
Minimal, classical style
@Value.Immutable
interface Book {
String isbn();
String title();
List<String> authors();
}
ImmutableBook book = ImmutableBook.builder()
.isbn("978-1-56619-909-4")
.title("The Elements of Style")
.addAuthors("William Strunk Jr.", "E.B. White.")
.build();
"sandwich" style, with nested builder and extending With* interface
…
See releases tab for release history. Archived changelog for earlier releases.
In-memory backend compares values by representation, so a stored 2.00 does not match a queried 2
In-memory backend throws NullPointerException when ordering by a nullable attribute
Builder from uses Guava immutables internally and can cause IllegalArgumentException
Encoding.Copy not copy annotation of methods
Compilation error when attributeBuilderDetection is used with overshadowImplementation
TYPE_USE annotations used for wildcard bounds are not retained
Jackson 3 annotations ignored when used as meta-annotations on package-info or parent interfaces
Skip invariant checks for items that are interned
Unexpected behaviour for Derived field depending on Default Optional fields