Skip to content
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

Merged
merged 2 commits into from
Jan 18, 2017

Conversation

mcxtzhang
Copy link
Contributor

@mcxtzhang mcxtzhang commented Jan 18, 2017

There is a missing symbol "?" in [$T for Types] - [Import static]

@@ -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)
Copy link
Collaborator

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")

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor

@sormuras sormuras Jan 18, 2017

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.

Copy link
Contributor

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... 😉

@sormuras
Copy link
Contributor

sormuras commented Jan 18, 2017

@mcxtzhang can you please insert two more ?s into JavaFileTest? This is where I copied the wrong documentation text section from. Line 44 and 72.

@mcxtzhang mcxtzhang changed the title Update README.md There is a missing symbol "?" in [$T for Types] - [Import static] Jan 18, 2017
@mcxtzhang mcxtzhang changed the title There is a missing symbol "?" in [$T for Types] - [Import static] There is a missing symbol ? in [$T for Types] - [Import static] Jan 18, 2017
@mcxtzhang mcxtzhang changed the title There is a missing symbol ? in [$T for Types] - [Import static] There is a missing symbol "?" in [$T for Types] - [Import static] Jan 18, 2017
@mcxtzhang
Copy link
Contributor Author

I've inserted them.

@sormuras
Copy link
Contributor

Merci!

@swankjesse swankjesse merged commit ff50d7b into square:master Jan 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants