Ignore:
Timestamp:
2017-09-15T01:20:41+02:00 (7 years ago)
Author:
Don-vip
Message:

see #11390 - SonarQube - squid:S3824 - "Map.get" and value test should be replaced with single method call

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/MultiMap.java

    r9790 r12865  
    6666     */
    6767    public void put(A key, B value) {
    68         Set<B> vals = map.get(key);
    69         if (vals == null) {
    70             vals = new LinkedHashSet<>();
    71             map.put(key, vals);
    72         }
    73         vals.add(value);
     68        map.computeIfAbsent(key, k -> new LinkedHashSet<>()).add(value);
    7469    }
    7570
     
    9590     */
    9691    public void putAll(A key, Collection<B> values) {
    97         Set<B> vals = map.get(key);
    98         if (vals == null) {
    99             vals = new LinkedHashSet<>(values);
    100             map.put(key, vals);
    101         }
    102         vals.addAll(values);
     92        map.computeIfAbsent(key, k -> new LinkedHashSet<>(values)).addAll(values);
    10393    }
    10494
Note: See TracChangeset for help on using the changeset viewer.