Fix build error by parsing fields having annotations #160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Code
I created an entity like this:
Error with two annotations
I configured my project as explained in the repository and when I execute the maven compilation, this error occurs:
Debug
Debugging the compilation in the part that causes the error ( method
parseNode
of the classTypeParser
):When the
TypeParser
tries to extract the type from the field email the variables
has the following value"@javax.validation.constraints.Email,@javax.validation.constraints.Size(max=255) java.lang.String"
Consequently, there is an error in the substring because it expects to find the char
<
.Error with one annotation
If I try to remove just one of the annotations and I execute the compilation again, another error occurs in the build:
Now the string s has this value:
"@javax.validation.constraints.Size(max=255) java.lang.String"
The class
MyEntity$
is not generated correctly because the import in the third row contains the type of the previous strings
Solution
In the end, I decided to fix both the errors with this pull request considering that the string can contain annotations avoiding to take them in the string type. I added also some unit tests to check these cases.