Merge pull request #15543 from igor-suhorukov

* pr/15543:
  Simplify code by using Map computeIfAbsent
This commit is contained in:
Stephane Nicoll 2018-12-21 11:13:24 +01:00
commit 6013146a9a
2 changed files with 2 additions and 10 deletions

View File

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

View File

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