Simplify code by using Map computeIfAbsent

Closes gh-15543
pull/15549/head
igor-suhorukov 6 years ago committed by Stephane Nicoll
parent b8c82ec425
commit cbf6b330ba

@ -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);
}

Loading…
Cancel
Save