Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

323
Vistas
Lombok's @Builder not detecting fields of the Java Record

I am trying to implement the builder pattern using Lombok's @Builder but it does not detect any of the record fields:

@Builder(builderMethodName = "internalBuilder")
public record ApiError(String title, Map<String, String> errors) {

    public static ApiErrorBuilder builder(String title) {
        return internalBuilder().title(title); // Cannot resolve method 'title' in 'ApiErrorBuilder'
    }
}

When I turn record to a class, everything works as expected:

@Builder(builderMethodName = "internalBuilder")
public class ApiError {

private final String title;
private final Map<String, String> errors;

    public ApiError(String title, Map<String, String> errors) {
        this.title = title;
        this.errors = errors;
    }

    public static ApiErrorBuilder builder(String title) {
        return internalBuilder().title(title);
    }

    // getters

}

Is this happening because Lombok currently does not work well with records yet?

I am using IntelliJ and Lombok 1.18.22

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

It is a known Intellij bug. There is, however, a workaround:

This doesn't work:

@Builder
public record MyRecord(String myField) {}

This does:

public record MyRecord(String myField) {
    @Builder public MyRecord {}
} 

Important: Once you insert the @builder inside the record, you must remove the @builder above it

over 4 years ago · Santiago Trujillo Denunciar

0

According to this records are supported from Lombok version v1.18.20

@Builder on records is supported since the last release v1.18.20. Which version are you using? Note that this may also be just an IDE issue. If you are using IntelliJ, it may not be supported, yet.

Probably an IntelliJ issue ... try writing the code without IntelliJ auto-complete, see if it compiles ... if it does ... its an IntelliJ issue ... if it does not, something is wrong with your code.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda