🌐
GitHub
github.com › Randgalt › record-builder
GitHub - Randgalt/record-builder: Record builder generator for Java records · GitHub
Can be used instead of new NameAndAge(...) */ public static NameAndAge NameAndAge(String name, int age) { return new NameAndAge(name, age); } /** * Return a new builder with all fields set to default Java values */ public static NameAndAgeBuilder builder() { return new NameAndAgeBuilder(); } /** * Return a new builder with all fields set to the values taken from the given record instance */ public static NameAndAgeBuilder builder(NameAndAge from) { return new NameAndAgeBuilder(from.name(), from.age()); } /** * Return a "with"er for an existing record instance */ public static NameAndAgeBuilder
Starred by 921 users
Forked by 70 users
Languages   Java
🌐
Baeldung
baeldung.com › home › java › a practical guide to recordbuilder in java
A Practical Guide to RecordBuilder in Java | Baeldung
November 12, 2025 - Learn about the RecordBuilder library to enhance Java records with a builder pattern, bridging the gap between the elegance of immutability and the practicality of flexible construction.
Discussions

Records and @Builder
It does not defeat the purpose. Records are immutable data objects. How you initialize them, is up to you and using the builder pattern on big data objects makes sense as sometimes the default record constructor might be inflexible. If you don't want to use lombok (@Builder), this works great: https://github.com/Randgalt/record-builder More on reddit.com
🌐 r/javahelp
12
2
September 2, 2024
Java record does not have default builder - Stack Overflow
Java came with records which are really useful and can avoid use of library like Project Lombok. But can someone please help me understand why records does not support Builder pattern by default? I More on stackoverflow.com
🌐 stackoverflow.com
ANN: Record Builder – Builder and Withers for Java 16 Records

I've mentioned this here before but now that Java 16 is released I've made a new release compiled with the latest Java 16.

Java 16 introduces Records. While this version of records is fantastic, it's currently missing some important features normally found in data classes: a builder and "with"ers. This project is an annotation processor that creates:

  • a companion builder class for Java records

  • an interface that adds "with" copy methods

  • an annotation that generates a Java record from an Interface template

More on reddit.com
🌐 r/java
8
30
March 16, 2021
Derived Record Creation (Draft JEP)
That composition of withers was really cool! I love how much Pattern Matching prioritizes composition. I also appreciated the identity example. The one where they did obj with {};. That really helps cement the mental model that this is really just a mirror relationship between a constructor and a deconstructor. I think the word they keep using is the Embedding-Projection pair. More on reddit.com
🌐 r/java
47
85
January 24, 2024
🌐
How to do in Java
howtodoinjava.com › home › java basics › builder pattern for java records
Builder Pattern for Java Records
August 6, 2024 - Learn to implement the builder pattern style fluent API and copy constructors in Java records for creating immutable records with examples.
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Java RecordBuilder Example - Java Code Geeks
August 13, 2025 - In this section, we will walk through a complete example of using RecordBuilder to create immutable Java records with a fluent builder API.
🌐
DEV Community
dev.to › agavrilov76 › record-companion-simple-builder-pattern-for-java-records-4h9f
Record Companion: Simple Builder Pattern for Java Records - DEV Community
September 21, 2025 - Record Companion focuses on simplicity and ease of use, making it perfect if you just want straightforward builder patterns without the extra bells and whistles. Java Records gave us immutable data structures. ValidCheck gave us clean validation.
🌐
Medium
medium.com › @sskmal › java-records-6736f45a6aa7
Java Records and Builder pattern For Record | by sunimal malkakulage | Medium
August 21, 2024 - Validation: You can add validation logic in the build() method or within individual setter methods in the builder, ensuring that only valid objects are constructed. While records are meant to be simple and straightforward, adding a builder class can make them more versatile, especially in more complex object construction scenarios.
🌐
Java Guides
javaguides.net › 2023 › 12 › builder-pattern-with-java-records.html
Builder Pattern with Java Records
March 17, 2024 - 2. Inside the Person record, a static Builder class is defined. 3. The Builder class has methods name, age, and email for setting properties and a build method to create a Person instance.
Find elsewhere
🌐
Coderanch
coderanch.com › t › 776593 › code-reviews › engineering › Java-Record-Builder-Practice
Java Record Builder Best Practice (Code Reviews forum at Coderanch)
September 16, 2023 - Validating the input parameters is covered by using a "custom constructor" in the record declaration. In your code it would look something like this: So that should take care of the validation part. That leaves the Builder to provide the fluid interface, which looks like it can't be made compulsory but maybe that isn't as much of a problem.
🌐
javaspring
javaspring.net › blog › java-records-builder
Java Records Builder: A Comprehensive Guide — javaspring.net
Instead of using a large constructor with many parameters, you use a builder class to set each parameter one by one and then build the final object. A Java Records Builder is a way to apply the builder pattern to records.
🌐
Medium
medium.com › @trivajay259 › builder-pattern-for-java-records-f62d884e9973
Builder Pattern for Java Records. The builder pattern aims to provide a… | by Ajay Kumar | Medium
March 12, 2026 - public record Team(String name, String description, String uuid, String photoPath) { public static final class Builder{ String name; String description; String uuid; String photoPath; public Builder uuid(String uuid) { this.uuid = uuid; return this; } public Builder description(String description) { this.description = description; return this; } public Builder name(String name) { this.name = name; return this; } public Builder status(String description) { this.description = description; return this; } public Team build() { return new Team(uuid, name, name, photoPath); } } }
🌐
Medium
medium.com › @pravin3c › 3-ways-to-create-builder-pattern-for-java-records-441cb3bc94b3
3 Ways to Create Builder Pattern for Java Records | by Pravin Choudhary | Medium
April 5, 2024 - 3 Ways to Create Builder Pattern for Java Records The Builder pattern, which is one of the 23 Gang of Four (GoF) design patterns, is a creational design pattern that lets you construct complex …
🌐
YouTube
youtube.com › watch
Complete Java Records Tutorial - YouTube
This Java Records tutorial is part of the full crash course published over on TheServerSide. Check it out!https://www.theserverside.com/video/How-Java-17-rec...
Published   March 25, 2024
🌐
GitHub
github.com › Pravin3c › Builder-Pattern-with-Java-Records
GitHub - Pravin3c/Builder-Pattern-with-Java-Records: Ways to Create Builder Pattern for Java Records · GitHub
1. Using Nested Static Class Step 1: Define the Record We start by defining an Employee record with multiple fields. public record Employee(Long id, String name, String company, Integer salary) {} Step 2: Create the Builder Class We then create ...
Author   Pravin3c
🌐
Baeldung
baeldung.com › home › java › core java › java record keyword
Java Record Keyword | Baeldung
November 5, 2025 - Since Java 14 (and as an official, standard language feature in Java 16), we can now use records to remedy these problems. In this tutorial, we’ll look at the fundamentals of records, including their purpose, generated methods, and customization techniques.
🌐
Oracle
docs.oracle.com › en-us › iaas › tools › java › latest › com › oracle › bmc › datalabelingservicedataplane › model › Record.Builder.html
Record.Builder (Oracle Cloud Infrastructure Java SDK - 3.90.0)
java.lang.Object · com.oracle.bmc.datalabelingservicedataplane.model.Record.Builder · Enclosing class: Record · public static class Record.Builder extends Object · clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait ·
Top answer
1 of 1
23

Records are not “Lombok-lite”

Recreating Lombok is not the purpose of Java record.

The purpose of Java record is to provide an explicit vehicle for transparently communicating shallowly-immutable data.

Technically, records are Java’s nominal tuple. Tuple means an ordered set of fields. Nominal means the fields have names, as does their container. Practically, you can think of a Java record as a struct on steroids.

See the official document for scope and purpose, JEP 395: Records.

So no Builder feature need be provided by default as that lies outside the scope of Java record. However, you can easily create your own Builder for any particular record class.

AI-generated

Actually, you need not write your own Builder implementation. Let a generative AI draft the code on your behalf. (Be sure to review carefully as these AIs are imperfect.)

For example:

write code for a Builder class for the Java record record Person ( String name , LocalDate birth ){}

Ecosia AI chat feature produces:

public record Person(String name, LocalDate birth) {
    
    public static class Builder {
        private String name;
        private LocalDate birth;

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder birth(LocalDate birth) {
            this.birth = birth;
            return this;
        }

        public Person build() {
            return new Person(name, birth);
        }
    }
}

That code worked for me, copy-pasted, with no edits needed.

Usage:

Person person = new Person.Builder()
    .birth(LocalDate.of(2001, Month.JANUARY, 23))
    .name("Alice")
    .build();

person.toString() // ➡️ Person[name=Alice, birth=2001-01-23]

Withers

By the way, work is underway to add “withers”, a feature to instantiate a new record object based on the payload values of another. See JEP 468: Derived Record Creation (Preview).

Jakarta Validation

You may want to use Jakarta Validation (previously known as Bean Validation) to verify the validity of your new record object’s state.

Likewise, you might use Jakarta Validation in your Builder implementation.

IDE code generation

Your IDE may have a feature for generating code for a Builder from a given Java Record.

For example, IntelliJ has a built-in feature Replace Constructor with Builder. However that does not work for Java Record. But there is a plugin for that. The Record Builder Plugin can “automatically generate builder classes for your Java Records, JavaBeans and Interfaces, allowing you to select fields and configure the generated builder”.

RecordBuilder library

RecordBuilder is an interesting project that lets you mark a Java record with an annotation. Then RecordBuilder generates code for builders and withers.

I’ve not yet tried using this library, so I cannot vouch for it.

🌐
Sonar
sonarsource.com › blog › builders-withers-and-records-java-s-path-to-immutability
Builders, Withers, and Records - Java’s path to immutability | Sonar
February 21, 2024 - In this article, I will talk about two different approaches to creating objects: Builders and Withers, typically used in the context of immutable objects, along with a new type of immutable object in Java: Records.
🌐
Community Platform
wearecommunity.io › communities › javaro › articles › 5372
Unlocking the Power of Java Records with RecordBuilder
Quick guide for RecordBuilder - an annotation processor that brings some missing parts to Java Records