-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
Iterate using Map entries #4003
Conversation
for (String stateVariable : values.keySet()) { | ||
StateVariableValue value = values.get(stateVariable); | ||
for (Entry<String, StateVariableValue> entry : values.entrySet()) { | ||
StateVariableValue value = entry.getValue(); | ||
if (value.getValue() != 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.
I think this null-check can be omitted if we use entry.getValue()
because the map has no null values.
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 getting NPE's I believe due to the removal of the null check here. I've opened #4037 to track that.
ConfigDescriptionParameter configDescriptionParameter = map.get(key); | ||
for (Entry<String, ConfigDescriptionParameter> entry : map.entrySet()) { | ||
String key = entry.getKey(); | ||
ConfigDescriptionParameter configDescriptionParameter = entry.getValue(); | ||
if (configDescriptionParameter != 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.
I think this null-check can be omitted if we use entry.getValue() because the map has no null values.
List<String> vendorPortfolio = entry.getValue(); | ||
return vendorPortfolio == null ? List.of() : vendorPortfolio; |
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.
List<String> vendorPortfolio = entry.getValue(); | |
return vendorPortfolio == null ? List.of() : vendorPortfolio; | |
return entry.getValue(); |
The map does not contain null values
Iteration using Map entries is preferred because it is more efficient and helps preventing NPEs. Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Wouter Born <github@maindrain.net>
b735611
to
c0a75e8
Compare
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.
Thanks!
* Iterate using Map entries Iteration using Map entries is preferred because it is more efficient and helps preventing NPEs. Signed-off-by: Wouter Born <github@maindrain.net> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
Iteration using Map entries is preferred because it is more efficient and helps preventing NPEs.