Generics cleanup#25
Open
dgruntz wants to merge 3 commits intoeppleton:masterfrom
dgruntz:generics-cleanup
Open
Generics cleanup#25dgruntz wants to merge 3 commits intoeppleton:masterfrom dgruntz:generics-cleanup
dgruntz wants to merge 3 commits intoeppleton:masterfrom
dgruntz:generics-cleanup
Conversation
The choice-box used in this example was declared as a raw type: ChoiceBox cb = new ChoiceBox(); This commit makes use of the generic type ChoiceBox<String> cb = new ChoiceBox<>();
Declares the TableView tableView as a generic type:
TableView<Player> tableView = new TableView<>();
However, with this change the method call
tableView.getColumns().addAll(firstName, lastName, goals);
leads to the warning "A generic array of TableColumn<Player,?> is
created for a varargs", therefore I added a suppress warnings
annotation.
Removes the cast to Player in the line
((Player) t.getTableView().getItems().get(t.getTablePosition()
.getRow())).setFirstName(t.getNewValue());
as this is given by the generics declaration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds generic declarations at some places (instead of the use of raw types). This may simplify the code (as casts can be dropped).
However, at one place this change leads to the warning "A generic array of TableColumn<Player,?> is
created for a varargs" and therefore I added a suppress warnings annotation, but I have seen in later projects that you have this problem in other classes as well and you have not added an ignore warnings annotation, so the one I have added could be removed.