Changeset 16628 in josm for trunk/src/org


Ignore:
Timestamp:
2020-06-14T14:55:29+02:00 (4 years ago)
Author:
simon04
Message:

see #19334 - https://errorprone.info/bugpattern/MixedMutabilityReturnType

Location:
trunk/src/org/openstreetmap/josm
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r16438 r16628  
    260260        if (list.size() == 1) {
    261261            // ways form a single line string
    262             return new ArrayList<>(list.iterator().next().getNodes());
     262            return Collections.unmodifiableList(new ArrayList<>(list.iterator().next().getNodes()));
    263263        }
    264264        return Collections.emptyList();
  • trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java

    r16505 r16628  
    283283            }
    284284        }
    285         return result;
     285        return Collections.unmodifiableList(result);
    286286    }
    287287
  • trunk/src/org/openstreetmap/josm/actions/corrector/TagCorrector.java

    r15586 r16628  
    211211            } else if (answer != JOptionPane.NO_OPTION)
    212212                throw new UserCancelException();
    213             return commands;
     213            return Collections.unmodifiableCollection(commands);
    214214        }
    215215
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r16553 r16628  
    409409                rels.stream().filter(r -> !dataSet.containsRelation(r)).forEachOrdered(col::add);
    410410            }
    411             return col;
     411            return Collections.unmodifiableCollection(col);
    412412        }
    413413    }
  • trunk/src/org/openstreetmap/josm/data/osm/Changeset.java

    r16433 r16628  
    475475            return Collections.emptyList();
    476476        }
    477         return new ArrayList<>(discussion);
     477        return Collections.unmodifiableList(discussion);
    478478    }
    479479
  • trunk/src/org/openstreetmap/josm/data/osm/NodeGraph.java

    r16445 r16628  
    375375            }
    376376        }
    377         return result;
     377        return Collections.unmodifiableSet(result);
    378378    }
    379379
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java

    r16333 r16628  
    242242            }
    243243            errors.addAll(result);
    244             return result;
     244            return Collections.unmodifiableList(result);
    245245        }
    246246        return Collections.emptyList();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/ConnectivityRelations.java

    r16445 r16628  
    120120            result.put(laneNumber, connections);
    121121        }
    122         return result;
     122        return Collections.unmodifiableMap(result);
    123123    }
    124124
  • trunk/src/org/openstreetmap/josm/data/validation/util/ValUtil.java

    r16119 r16628  
    8686            cells.add(cellWays.computeIfAbsent(cell, k -> new ArrayList<>()));
    8787        }
    88         return cells;
     88        return Collections.unmodifiableList(cells);
    8989    }
    9090
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r16619 r16628  
    11081108            drawImageInside(g, img, anchorImage, anchorScreen, clip);
    11091109        }
    1110         return missedTiles;
     1110        return Collections.unmodifiableList(missedTiles);
    11111111    }
    11121112
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java

    r16590 r16628  
    44import java.awt.Color;
    55import java.nio.charset.StandardCharsets;
    6 import java.util.ArrayList;
    76import java.util.Arrays;
    8 import java.util.Collection;
    97import java.util.Collections;
    108import java.util.List;
     
    1210import java.util.Map.Entry;
    1311import java.util.Objects;
    14 import java.util.TreeSet;
    1512import java.util.regex.Matcher;
    1613import java.util.regex.Pattern;
     
    4138import org.openstreetmap.josm.tools.RightAndLefthandTraffic;
    4239import org.openstreetmap.josm.tools.RotationAngle;
     40import org.openstreetmap.josm.tools.StreamUtils;
    4341import org.openstreetmap.josm.tools.Territories;
    4442import org.openstreetmap.josm.tools.Utils;
     
    476474        if (env.parent == null) {
    477475            if (env.osm != null) {
    478                 final Collection<String> tags = new TreeSet<>(AlphanumComparator.getInstance());
    479476                // we don't have a matched parent, so just search all referrers
    480                 for (IPrimitive parent : env.osm.getReferrers()) {
    481                     String value = parent.get(key);
    482                     if (value != null) {
    483                         tags.add(value);
    484                     }
    485                 }
    486                 return new ArrayList<>(tags);
     477                return env.osm.getReferrers().stream().map(parent -> parent.get(key))
     478                        .filter(Objects::nonNull)
     479                        .distinct()
     480                        .sorted(AlphanumComparator.getInstance())
     481                        .collect(StreamUtils.toUnmodifiableList());
    487482            }
    488483            return Collections.emptyList();
  • trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java

    r16553 r16628  
    819819                }
    820820            }
    821             return dividers;
     821            return Collections.unmodifiableList(dividers);
    822822        } else
    823823            return Collections.emptyList();
  • trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java

    r14946 r16628  
    182182                monitor.worked(1);
    183183            }
    184             return ret;
     184            return Collections.unmodifiableList(ret);
    185185        } catch (OsmTransferException e) {
    186186            throw e;
  • trunk/src/org/openstreetmap/josm/tools/WinRegistry.java

    r14977 r16628  
    202202        }
    203203        regCloseKey.invoke(root, getNumber(handles, 0));
    204         return results;
     204        return Collections.unmodifiableMap(results);
    205205    }
    206206
     
    226226        }
    227227        regCloseKey.invoke(root, getNumber(handles, 0));
    228         return results;
     228        return Collections.unmodifiableList(results);
    229229    }
    230230
Note: See TracChangeset for help on using the changeset viewer.