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

361
Vistas
Edit lombok getter method name for boolean member having prefix "has"

I am having a boolean variable hasObject in lombok which generates isHasObject(). I am using @Data lombok annotation. How can i change the method to hasObject()

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

0

in your case it could be:

 class XY : Object {
      @Getter(fluent = true)
      public boolean hasObject;
 }

OR

 @Accessors(fluent = true)
 class XY : Object {
      public boolean hasObject;
 }

according to the docs:

fluent - A boolean. If true, the getter for pepper is just pepper(), and the setter is pepper(T newValue). Furthermore, unless specified, chain defaults to true. Default: false.

over 4 years ago · Santiago Trujillo Denunciar

0

I found out help from lombok-how-to-customise-getter-for-boolean-object-field. By this I will be have the altering accessor level and the code getter old fashion,

@Getter(AccessLevel.NONE) private boolean hasObject;

public boolean hasObject() {
    return hasObject;
}

I will be keeping this question open. Is this the only way to change getter method name or I will wait for better suggestions.

over 4 years ago · Santiago Trujillo Denunciar

0

Combining the Accessors and Getter, you might get the folllowing:

 class ExampleClass {
      @Accessors(fluent = true)
      @Getter
      private boolean hasObject;
 }

is an equivalent to the Vanilla Java:

class ExampleClass {
    
    private boolean hasObject;

    public hasObject() {
        return hasObject;
    }

Which is what you wanted, I guess.

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