Merge pull request #15543 from igor-suhorukov

* pr/15543:
  Simplify code by using Map computeIfAbsent
pull/15549/head
Stephane Nicoll 6 years ago
commit 6013146a9a

@ -104,11 +104,7 @@ class TypeElementMembers {
else if (isSetter(method)) { else if (isSetter(method)) {
String propertyName = getAccessorName(name); String propertyName = getAccessorName(name);
List<ExecutableElement> matchingSetters = this.publicSetters List<ExecutableElement> matchingSetters = this.publicSetters
.get(propertyName); .computeIfAbsent(propertyName, (k) -> new ArrayList<>());
if (matchingSetters == null) {
matchingSetters = new ArrayList<>();
this.publicSetters.put(propertyName, matchingSetters);
}
TypeMirror paramType = method.getParameters().get(0).asType(); TypeMirror paramType = method.getParameters().get(0).asType();
if (getMatchingSetter(matchingSetters, paramType) == null) { if (getMatchingSetter(matchingSetters, paramType) == null) {
matchingSetters.add(method); matchingSetters.add(method);

@ -136,11 +136,7 @@ public class ConfigurationMetadata {
} }
private <K, V> void add(Map<K, List<V>> map, K key, V value) { private <K, V> void add(Map<K, List<V>> map, K key, V value) {
List<V> values = map.get(key); List<V> values = map.computeIfAbsent(key, (k) -> new ArrayList<>());
if (values == null) {
values = new ArrayList<>();
map.put(key, values);
}
values.add(value); values.add(value);
} }

Loading…
Cancel
Save