Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

v1.9

Compare
Choose a tag to compare
@alicederyn alicederyn released this 26 Apr 17:01

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"));