Releases: inferred/FreeBuilder
v1.10.8
This release fixes Java 9 compiler errors by omitting the @Generated
annotation if unavailable.
Note: v1.10.7 has been skipped due to build infrastructure issues.
v1.10.6
Builder.from
now reuses ImmutableList and ImmutableSet instances where possible, reducing the memory overhead of the modify-rebuild pattern.
v1.10.5
v1.10.4
This release fixes mergeFrom
to always ignore default values in the merged-in builder/value instance (issues #97, #98).
@FreeBuilder
public interface Value {
String property;
class Builder extends Value_Builder {
public Value() {
setProperty("default");
}
}
}
Previously, for this type, valueBuilder.setProperty("a").mergeFrom(new Value.Builder())
would incorrectly overwrite the "a" in valueBuilder with "default"; as of this release, the property will retain the value "a".
v1.10.3
v1.10.2
v1.10.1
v1.10
v1.9
This release adds map and mutate methods to builders when compiled with Java 8+ (issue #6), and allows builder classes to be declared abstract (#126).
Java 8+'s lambda methods allow a more fluent approach to updating properties on a Builder. For example, to increment a property:
Person olderPerson = new Person.Builder()
.mergeFrom(person)
.mapAge(age -> age + 1)
.build();
To delete part of a list:
personBuilder.mutateDescendants(d -> d.subList(3, 5).clear());
To update part of a property with its own builder:
projectBuilder.mutateOwner(b -> b
.setName("Phil")
.setDepartment("HR"));
v1.8
This release stops FreeBuilder throwing IllegalStateExceptions when overwriting an entry in a map property, or attempting to remove an entry that is not there, bringing it in line with how the Map interface works.
FreeBuilder previously followed ImmutableMap.Builder's lead in throwing IllegalStateExceptions when putting an entry for a key already present in the map. As FreeBuilder types are frequently subject to modifications rather than always created from scratch, this has turned out to be a bad match for real-world usage. Since the behaviour is changing to be more permissive, i.e. to allow actions that would previously have thrown exceptions, this change is backwards-compatible.