Commit 6013146a authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #15543 from igor-suhorukov

* pr/15543:
  Simplify code by using Map computeIfAbsent
parents b8c82ec4 cbf6b330
......@@ -104,11 +104,7 @@ class TypeElementMembers {
else if (isSetter(method)) {
String propertyName = getAccessorName(name);
List<ExecutableElement> matchingSetters = this.publicSetters
.get(propertyName);
if (matchingSetters == null) {
matchingSetters = new ArrayList<>();
this.publicSetters.put(propertyName, matchingSetters);
}
.computeIfAbsent(propertyName, (k) -> new ArrayList<>());
TypeMirror paramType = method.getParameters().get(0).asType();
if (getMatchingSetter(matchingSetters, paramType) == null) {
matchingSetters.add(method);
......
......@@ -136,11 +136,7 @@ public class ConfigurationMetadata {
}
private <K, V> void add(Map<K, List<V>> map, K key, V value) {
List<V> values = map.get(key);
if (values == null) {
values = new ArrayList<>();
map.put(key, values);
}
List<V> values = map.computeIfAbsent(key, (k) -> new ArrayList<>());
values.add(value);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment