-
-
Notifications
You must be signed in to change notification settings - Fork 1k
#1601 Immutables fluent getters support #3914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…into 1601-immutables-fluent-getters
|
Closes #1601 |
filiphr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code I am not sure that this works @thmasker. I've approved the CI to run, so let's see. In any case, I think we need a better more granular support here
| private boolean isFluentGetter(ExecutableElement method) { | ||
| return method.getParameters().isEmpty() && | ||
| method.getReturnType().getKind() != TypeKind.VOID && | ||
| !JAVA_JAVAX_PACKAGE.matcher( method.getEnclosingElement().asType().toString() ).matches(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we should just make this like this. We should look at the Immutables @Styles, see https://immutables.github.io/style.html and determine based on that.
Otherwise, this just applies to everything.
Additionally, I really do not understand how this even works, the getElementName is not overridden, so I don't think that this works properly
| var item = ImmutableItemDto.builder().id( "test" ).build(); | ||
|
|
||
| var target = ItemMapper.INSTANCE.map( item ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use var. We don't have a check for this, but I am not a fan of it and we are not using it anywhere else in our codebase.
The test fails. I need to somehow differentiate fluent getters from other methods without parameters and with return type that are not getters. Any idea is appreciated, as I haven't been able to find a way so far... for example,
ImmutableItemDto#idmatches alsoImmutableItem.Builder#build