-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use Objects.requireNonNull
wherever possible
#1200
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,16 +75,14 @@ ${modifiers}class $subclass$formalTypes extends $origClass$actualTypes { | |
## the constructor is called from the extension code. | ||
|
||
#if ($identifiers) | ||
if ($p == null) { | ||
throw new NullPointerException("Null $p.name"); | ||
} | ||
this.$p = `java.util.Objects`.requireNonNull($p, "Null $p"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change makes sense. However, the indentation convention in this file is that Velocity directives (like (It happens that the code indentation doesn't matter because a separate indentation pass will fix it up anyway, but I think following the conventions makes the code easier to follow.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed indentation. Please let me know if I missed something. |
||
#else | ||
`java.util.Objects`.requireNonNull($p); | ||
this.$p = `java.util.Objects`.requireNonNull($p); | ||
#end | ||
|
||
#end | ||
|
||
#else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that there is now an
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it looks better that way. |
||
this.$p = $p; | ||
#end | ||
#end | ||
} | ||
|
||
|
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'm not sure I understand why the changes in this file need to be anything more than changing
if (x == null)
+throw new NPE(msg)
intoObjects.requireNonNull(x, msg)
. And, in fact the opportunity to do so on line 76 seems to have been missed.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.
Refactored.