Tag Archives: builders

Build Java records with builders

When writing Java record withers what and when I discovered that the Java beans with builders resulting from Build beans better with builders could have their boiler plate code size reduced to half, if they were turned into records instead of beans.

This is the story of switching my Java beans to records and how that worked with jackson to build JSON objects from records and parse JSON objects into records. Continue reading Build Java records with builders

Java record withers what and when

This blog post is the result of searching the internet to find out what Java records with “withers” will look like and in what version of Java records with withers will arrive.

In addition, while trying to figure out Java withers, I discovered that reforming my current beans with builders into records with builders, I could throw away half the boiler plate code. Continue reading Java record withers what and when

Build beans better with builders

Edit: I no longer use beans with builders, I Build Java records with builders

Builders provide a nice, if verbose, way to create immutable java beans.

The upsides are a nice syntax for creating immutable beans, and a way to provide copy-on-write behaviour for immutable objects.

The downsides are the need for verbose boilerplate code, approximately doubling the code size of the bean source files, and the overhead of one extra object created and then left for garbage collection, for each created bean.

Continue reading Build beans better with builders