-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
There is a missing symbol "?" in [$T for Types] - [Import static] #537
Conversation
@@ -320,7 +320,7 @@ MethodSpec beyond = MethodSpec.methodBuilder("beyond") | |||
.addStatement("result.add($T.createNimbus(\"2001\"))", hoverboard) | |||
.addStatement("result.add($T.createNimbus($T.THUNDERBOLT))", hoverboard, namedBoards) | |||
.addStatement("$T.sort(result)", Collections.class) | |||
.addStatement("return result.isEmpty() $T.emptyList() : result", Collections.class) | |||
.addStatement("return result.isEmpty() ? $T.emptyList() : result", Collections.class) |
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.
More importantly, I think this isEmpty
check is useless (technically, in the generated code it definitely is; but it doesn't even add anything to the example either). I suggest replacing the line with:
.addStatement("return result")
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.
This is an example for using Import static
.
I think $T.emptyList()
is more importantly.
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's already the $T.sort(result)
above.
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.
Now I tend to agree with @mcxtzhang ... if only Collections.sort
was to be imported, it'd be better to use a single static type import instead of the *
version.
The additional value is to demonstrate the usage of .addStaticImport(Collections.class, "*")
with a Class<?>
instance.
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.
Now, only an Enum
constant overload demo is missing... 😉
@mcxtzhang can you please insert two more |
?
in [$T for Types] - [Import static]
?
in [$T for Types] - [Import static]
I've inserted them. |
Merci! |
There is a missing symbol "?" in [$T for Types] - [Import static]