Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

481
Visualizações
Lombok annotation @Getter for boolean field

I am using Java lombok annotation @Getter to generate getters for my POJO. I have a boolean field by the name isAbc.

The @Getter annotation in this case generates a method by the name isAbc(). Shouldn't it generate a method by the name isIsAbc()?

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Read the 'small print' section on the lombok page https://projectlombok.org/features/GetterSetter.html

For boolean fields that start with is immediately followed by a title-case letter, nothing is prefixed to generate the getter name.

So the behavior you experience is as specified.

Note that the behavior is different for boolean and Boolean:

@Getter
private boolean isGood; // => isGood()

@Getter
private boolean good; // => isGood()

@Getter
private Boolean isGood; // => getIsGood()
about 4 years ago · Santiago Trujillo Relatório

0

Lombok does not prefix with is if the name already starts with is followed by an uppercase letter as in isGood.

You might encounter names like canDelete which will generate a getter with the name isCanDelete. To avoid this you can use the fluent parameter:

@Getter(fluent = true)
private boolean canDelete;

or (depending on version):

@Getter
@Accessors(fluent = true)
private boolean canDelete;

In which case it will leave the name as it is so the getter becomes canDelete().

about 4 years ago · Santiago Trujillo Relatório

0

I do some tests against the lombok(1.16.8), and the conclusions are as below.

private Boolean good;

getter => getGood()              Boolean
setter => setGood(Boolean good)  void 


private boolean good;

getter => isGood()               boolean
setter => setGood(boolean good)  void 


private Boolean isGood;

getter => getIsGood()            Boolean
setter => setIsGood()            void 


private boolean isGood;

getter => isGood()               boolean
setter => setGood(boolean good)  void
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda