-
-
Notifications
You must be signed in to change notification settings - Fork 41
#159 support fluent setters with super types (e.g. lomboks @SuperBuilder) #161
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
Conversation
|
Check my comment in #159 (comment). Is the test code working even properly with the MapStruct processor. We don't really support |
|
@filiphr Could you please have another look? I think it is now valid to support super types like this in the IDE plugin. |
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.
Looks good @thunderhook, I've added some small comments
| return Arrays.stream( returnType.getSuperTypes() ) | ||
| .anyMatch( superType -> isAssignableFrom( psiType, superType ) ); |
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.
There is no need to create a stream and then use anyMatch. Let's just iterate through the returnType.getSuperTypes() and do a check in the for loop.
|
|
||
| private static boolean isAssignableFromReturnTypeOrSuperTypes(PsiType psiType, @Nullable PsiType returnType) { | ||
|
|
||
| if ( returnType == null ) { |
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.
The returnType cannot be null because in isFluentSetter we are checking method.getReturnType() != null.
|
@filiphr Thanks for the feedback. I have made the requested changes. |
I hope this change has no unwanted side effects. It checks whether a fluent setters return type also can be assigned to one of its super types to support classes like this:
Fixes #159