• Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

209
Views
Lombok @Data annotation changes the name of a field from isood to good

I have this DTO which uses @Data annotation of lombok in order to generate getters and setters:

@Data
public class SomeDto {

  protected boolean isGood;
}

The weird thing is that now my getter has been renamed from getisGood() to isGood() and the setter has the name setGood() instead of setIsGood(). Example:

SomeDto somedto = new SomeDto()
somedto.setGood(false) //sets the value to false - should have been setIsGood
somedto.isGood() //return false - should have been getIsGood

Also when I make a request on the endpoint where I use this DTO in the JSON returns:

{"good": false}

whereas is should has been :

{"isGood": false}

Anyone has any idea what the problem is? I have a suspicion that the "is" in the beginning of isGood creates maybe a confusion for lombok. I appreciate any help you can provide.

11 months ago · Santiago Trujillo
1 answers
Answer question

0

I guess the convention is that for a boolean, the getter is called isGood, while the setter is setGood. So your boolean is expected to be called just "good".

Here is one discussion

Also in the documentation :)

 lombok.getter.noIsPrefix = [true | false] (default: false)
    If set to true, getters generated for boolean fields will use the get prefix instead of the defaultis prefix, and any generated code that calls getters, such as @ToString, will also use get instead of is 

Docs

11 months ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.