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.

Answer from Basil Bourque on Stack Overflow
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.

🌐
GitHub
github.com › randgalt › record-builder
GitHub - Randgalt/record-builder: Record builder generator for Java records · GitHub
RecordBuilder can generate records and builders from deconstructor-style methods in any Java class.
Starred by 923 users
Forked by 70 users
Languages   Java
🌐
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.
🌐
How to do in Java
howtodoinjava.com › home › java basics › builder pattern for java records
Builder Pattern for Java Records
August 6, 2024 - The builder pattern aims to provide a flexible solution for constructing complex data structures by separating the build process from the final representation of the data structure.
🌐
Baeldung
baeldung.com › home › java › a practical guide to recordbuilder in java
A Practical Guide to RecordBuilder in Java | Baeldung
November 12, 2025 - It generates fluent, immutable-friendly builders that remove the need for manual constructors or update methods. Its real strength is balance: flexible updates without losing immutability, and expressive code without boilerplate. Whether we’re building DTOs, API responses, or config objects, it fits naturally into our workflow. With almost no setup, RecordBuilder becomes a powerful tool for clean, scalable Java development.
🌐
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 - Java has evolved its approach to immutability through three key patterns: the Builder pattern for constructing complex objects, withers (copy-with-modification methods) for creating modified copies, and Java Records for concisely declaring immutable data carriers.
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 - You can still provide a record type with a builder class to make it easier to construct certain complex records. And yes, I would make the builder class a nested class of the record type. Note that the term "inner class" explicitly refers to non-static nested classes. Say "nested class" instead. Honestly, I'm a little disappointed with records in Java.
🌐
Steinar Bangs blogg
steinar.bang.priv.no › 2024 › 05 › 09 › java-record-withers-what-and-when
Java record withers what and when | Steinar Bangs blogg
May 10, 2024 - The JEP for “withers”, JEP 468: Derived Record Creation (Preview), mentions Java 23, which is targeted for June 2024. Also, there is an Inside Java Newscast that mentions Java 23 as the target. Unfortunately JEP 468 is not on Java 23’s own list of JEPs at least not yet. But we can hope: if not in Java 23, then maybe in the next one? But in the meantime I will start out by transforming my current immutable beans with builders to records with builders.
🌐
TutorialsPoint
tutorialspoint.com › article › what-are-java-records-and-how-to-use-them-alongside-constructors-and-methods
What are Java Records and How to Use them Alongside Constructors and Methods?
July 19, 2023 - Java Records are a powerful tool for creating simple, immutable data carrier classes, reducing boilerplate code and improving code readability. They seamlessly work alongside constructors and methods to provide a simplified programming model.
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Java RecordBuilder Example - Java Code Geeks
August 13, 2025 - The RecordBuilder is a Java library designed to automatically generate builder classes for Java Records. Introduced in Java 14 (as a preview) and standardized in Java 16, records are immutable data carriers that reduce boilerplate code.
🌐
Medium
medium.com › @marian.jureczko › arranging-java-records-d11ec9141fde
Arranging Java Records. With the test-arranger (a library… | by Marian Jureczko | Medium
June 30, 2022 - Currently (two weeks after publishing the post), I’m using IntelliJ IDEA 2022.1.3 and it does not complain about Lombok’s annotations placed directly on records anymore. As a consequence, I can rid of the canonical constructor and simplify the example to: @Builder(toBuilder = true) record Data(int value, String name) { }
🌐
GUID Generator
guidgenerator.com
Free Online GUID Generator
Free Online GUID / UUID Generator · GUID (aka UUID) is an acronym for 'Globally Unique Identifier' (or 'Universally Unique Identifier'). It is a 128-bit integer number used to identify resources. The term GUID is generally used by developers working with Microsoft technologies, while UUID ...
🌐
Jenkov
jenkov.com › tutorials › java › record.html
Java Record
May 15, 2020 - You can add as many extra constructors as makes sense for your concrete Java Record definition. You can add instance methods to a Java Record definition - just like you can with a regular Java class.
🌐
Search
jrlybv.shop › !rn1jd9gureqs3njrrz › 541753.html
Java record builder default - jrlybv.shop
March 23, 2026 - Set in Guatemala's western highlands, Lake Atitlán
🌐
Project Lombok
projectlombok.org › features › Builder
@Builder
The sorted collections (java.util: ... that the type argument of the collection has natural order (implements java.util.Comparable). There is no way to pass an explicit Comparator to use in the builder....
🌐
Mockaroo
mockaroo.com
Mockaroo - Random Data Generator and API Mocking Tool | JSON / CSV / SQL / Excel
A free test data generator and API mocking tool - Mockaroo lets you create custom CSV, JSON, SQL, and Excel datasets to test and demo your software.
🌐
Baeldung
baeldung.com › home › java › core java › java record keyword
Java Record Keyword | Baeldung
November 5, 2025 - Records are immutable data classes that require only the type and name of fields. The equals, hashCode, and toString methods, as well as the private, final fields and public constructor, are generated by the Java compiler.
🌐
JetBrains
plugins.jetbrains.com › plugin › 24331-record-builder
Record Builder - IntelliJ IDEs Plugin | Marketplace
The Record Builder Plugin for IntelliJ offers an effortless way to use the Builder Pattern in your Java code. This plugin allows you to automatically generate builder...