generate hasFOO() for boolean fields named 'hasFOO' instead of 'isHasFOO' #77

Closed
lombokissues opened this Issue Jul 14, 2015 · 6 comments

Projects

None yet

3 participants

@lombokissues
Collaborator

Migrated from Google Code (issue 4)

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Jul 24, 2009 at 04:17 UTC

What steps will reproduce the problem?

  1. Create a class with a field named 'hasX', typed 'boolean'.
  2. Put a @ Data annotation on it.
  3. Get annoyed by the 'isHasX()' name. 'hasX()' is most likely far more appropriate.

Fix: If boolean field and the field name starts with 'has', use the field name as method name.

@lombokissues
Collaborator

๐Ÿ‘ค r.spilker ย  ๐Ÿ•— Jul 24, 2009 at 11:04 UTC

Also, we might want to check if any of the is/has/get methods exists befor creating
one.

@lombokissues
Collaborator

๐Ÿ‘ค r.spilker ย  ๐Ÿ•— Jul 25, 2009 at 21:10 UTC

If the field starts with "is" we don't want to prepend another "is". We need to make
sure that "is" or "has" is not the start of a longer word. So the next character has to
be title case. This ensures that a boolean field called hashCodeCalculated would get a
getter named isHashCodeCalculated instead of hasHCodeCalculated.

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Jul 26, 2009 at 07:19 UTC

Implemented all suggested changes in commit a9d2989.

NB: Roel, I haven't tested all borderline cases on this one!

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Jul 26, 2009 at 07:30 UTC

Test ๏นŸ1: Make boolean fields named 'isFoo', 'getBar', 'hasBaz' and 'hashFlooble'. This must generate methods
'isFoo(), hasBaz, getBar, and isHashFlooble.

On eclipse: Correct on all counts.

On javac: Correct on all counts.

Test ๏นŸ2: Make boolean fields named 'isFoo', 'bar'. Then make methods named 'hasFoo', and 'getBar', and make
sure that neither field gets an auto-generated getter, and that both fields get a warning that no getter is
being made, with the alternate name stated in the warning message.

on eclipse: correct on all counts.

on javac: correct on all counts.

Thus, I'm verifying the change.

@lombokissues
Collaborator

End of migration

@Tradunsky Tradunsky pushed a commit to Tradunsky/lombok that referenced this issue Aug 19, 2015
Michail Plushnikov continue work on @Singular support
Issue #77
739f4d4
@Tradunsky Tradunsky pushed a commit to Tradunsky/lombok that referenced this issue Aug 19, 2015
Michail Plushnikov updated Intellij-Version
Issue #77
8f0f5c1
@Tradunsky Tradunsky pushed a commit to Tradunsky/lombok that referenced this issue Aug 19, 2015
Michail Plushnikov Issue #77
added validation of @Singular Field Type
70a8c71
@Tradunsky Tradunsky pushed a commit to Tradunsky/lombok that referenced this issue Aug 19, 2015
Michail Plushnikov Issue #77
added test class data from lombok project
02dd105
@Tradunsky Tradunsky pushed a commit to Tradunsky/lombok that referenced this issue Aug 19, 2015
Michail Plushnikov Issue #77
added more validation for @Singular
c69f030
@Tradunsky Tradunsky pushed a commit to Tradunsky/lombok that referenced this issue Aug 19, 2015
Michail Plushnikov #77
improved delombok code generation for @Singular Builder (generic parameters)
9f111e3
@Tradunsky Tradunsky pushed a commit to Tradunsky/lombok that referenced this issue Aug 19, 2015
Michail Plushnikov #77
improved delombok code generation for @Singular Builder (build Method and guava collections)
8e3c220
@Tradunsky Tradunsky pushed a commit to Tradunsky/lombok that referenced this issue Aug 19, 2015
Michail Plushnikov #77
improved delombok code generation for @Singular Builder (build Method)
e92679a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment