Changeset 13206 in josm for trunk/src


Ignore:
Timestamp:
2017-12-17T00:42:54+01:00 (7 years ago)
Author:
Don-vip
Message:

enable PMD rule OptimizableToArrayCall

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

Legend:

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

    r13132 r13206  
    8585     */
    8686    protected static Layer askTargetLayer(List<Layer> targetLayers) {
    87         return askTargetLayer(targetLayers.toArray(new Layer[targetLayers.size()]),
     87        return askTargetLayer(targetLayers.toArray(new Layer[0]),
    8888                tr("Please select the target layer."),
    8989                tr("Select target layer"),
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r12636 r13206  
    169169        tree.updateTree(wms);
    170170        List<String> wmsFormats = wms.getFormats();
    171         final JComboBox<String> formats = new JComboBox<>(wmsFormats.toArray(new String[wmsFormats.size()]));
     171        final JComboBox<String> formats = new JComboBox<>(wmsFormats.toArray(new String[0]));
    172172        formats.setSelectedItem(wms.getPreferredFormats());
    173173        formats.setToolTipText(tr("Select image format for WMS layer"));
  • trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java

    r12846 r13206  
    249249     */
    250250    Collection<DownloadTask> askWhichTasksToLoad(final Collection<DownloadTask> tasks) {
    251         final JList<DownloadTask> list = new JList<>(tasks.toArray(new DownloadTask[tasks.size()]));
     251        final JList<DownloadTask> list = new JList<>(tasks.toArray(new DownloadTask[0]));
    252252        list.addSelectionInterval(0, tasks.size() - 1);
    253253        final ExtendedDialog dialog = new WhichTasksToPerformDialog(list);
  • trunk/src/org/openstreetmap/josm/actions/PurgeAction.java

    r13130 r13206  
    149149                return Long.compare(o1.getUniqueId(), o2.getUniqueId());
    150150            });
    151             JList<OsmPrimitive> list = new JList<>(toPurgeAdditionally.toArray(new OsmPrimitive[toPurgeAdditionally.size()]));
     151            JList<OsmPrimitive> list = new JList<>(toPurgeAdditionally.toArray(new OsmPrimitive[0]));
    152152            /* force selection to be active for all entries */
    153153            list.setCellRenderer(new SelectionForcedOsmPrimitivRenderer());
  • trunk/src/org/openstreetmap/josm/actions/RestartAction.java

    r12846 r13206  
    106106            public void run() {
    107107                try {
    108                     Runtime.getRuntime().exec(cmd.toArray(new String[cmd.size()]));
     108                    Runtime.getRuntime().exec(cmd.toArray(new String[0]));
    109109                } catch (IOException e) {
    110110                    Logging.error(e);
  • trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java

    r13173 r13206  
    170170            this.selection = selection;
    171171            this.wayToKeep = wayToKeep;
    172             this.list = new JList<>(newWays.toArray(new Way[newWays.size()]));
     172            this.list = new JList<>(newWays.toArray(new Way[0]));
    173173            configureList();
    174174
  • trunk/src/org/openstreetmap/josm/command/SequenceCommand.java

    r13173 r13206  
    4242        super(ds);
    4343        this.name = name;
    44         this.sequence = sequenz.toArray(new Command[sequenz.size()]);
     44        this.sequence = sequenz.toArray(new Command[0]);
    4545        this.continueOnError = continueOnError;
    4646    }
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r13173 r13206  
    5454
    5555            if (members != null) {
    56                 this.members = members.toArray(new RelationMember[members.size()]);
     56                this.members = members.toArray(new RelationMember[0]);
    5757            } else {
    5858                this.members = new RelationMember[0];
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r13173 r13206  
    6363                this.nodes = new Node[0];
    6464            } else {
    65                 this.nodes = nodes.toArray(new Node[nodes.size()]);
     65                this.nodes = nodes.toArray(new Node[0]);
    6666            }
    6767            for (Node node: this.nodes) {
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r13173 r13206  
    16101610
    16111611            // We use parallel sort here. This is only available for arrays.
    1612             StyleRecord[] sorted = allStyleElems.toArray(new StyleRecord[allStyleElems.size()]);
     1612            StyleRecord[] sorted = allStyleElems.toArray(new StyleRecord[0]);
    16131613            Arrays.parallelSort(sorted, null);
    16141614
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java

    r12881 r13206  
    1515
    1616import org.openstreetmap.josm.Main;
    17 import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;
    18 import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener;
    1917import org.openstreetmap.josm.data.coor.EastNorth;
    2018import org.openstreetmap.josm.data.osm.DataSet;
     
    2927import org.openstreetmap.josm.data.projection.Projection;
    3028import org.openstreetmap.josm.spi.preferences.Config;
     29import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;
     30import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener;
    3131import org.openstreetmap.josm.tools.Geometry;
    3232import org.openstreetmap.josm.tools.Geometry.AreaAndPerimeter;
     
    580580    public static Collection<JoinedWay> joinWays(Collection<Way> waysToJoin) {
    581581        final Collection<JoinedWay> result = new ArrayList<>();
    582         final Way[] joinArray = waysToJoin.toArray(new Way[waysToJoin.size()]);
     582        final Way[] joinArray = waysToJoin.toArray(new Way[0]);
    583583        int left = waysToJoin.size();
    584584        while (left > 0) {
  • trunk/src/org/openstreetmap/josm/data/validation/routines/InetAddressValidator.java

    r11930 r13206  
    146146                octetList.remove(0);
    147147            }
    148             octets = octetList.toArray(new String[octetList.size()]);
     148            octets = octetList.toArray(new String[0]);
    149149        }
    150150        if (octets.length > IPV6_MAX_HEX_GROUPS) {
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferable.java

    r11113 r13206  
    5656            flavors.addAll(OsmLayerTransferData.FLAVORS);
    5757        }
    58         return flavors.toArray(new DataFlavor[flavors.size()]);
     58        return flavors.toArray(new DataFlavor[0]);
    5959    }
    6060
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

    r13130 r13206  
    251251            build();
    252252            lblMessage.setText(msg);
    253             lstLayers.setListData(infos.toArray(new SaveLayerInfo[infos.size()]));
     253            lstLayers.setListData(infos.toArray(new SaveLayerInfo[0]));
    254254        }
    255255
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r13077 r13206  
    16491649        actions.add(SeparatorLayerAction.INSTANCE);
    16501650        actions.add(new LayerListPopup.InfoAction(this));
    1651         return actions.toArray(new Action[actions.size()]);
     1651        return actions.toArray(new Action[0]);
    16521652    }
    16531653
  • trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java

    r13165 r13206  
    392392        actions.add(new LayerSaveAction(this));
    393393        actions.add(new LayerSaveAsAction(this));
    394         return actions.toArray(new Action[actions.size()]);
     394        return actions.toArray(new Action[0]);
    395395    }
    396396
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r13161 r13206  
    681681                SeparatorLayerAction.INSTANCE,
    682682                new LayerListPopup.InfoAction(this)));
    683         return actions.toArray(new Action[actions.size()]);
     683        return actions.toArray(new Action[0]);
    684684    }
    685685
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r12620 r13206  
    8282        ret.add(new LayerSaveAsAction(this));
    8383        ret.add(new BookmarkWmsAction());
    84         return ret.toArray(new Action[ret.size()]);
     84        return ret.toArray(new Action[0]);
    8585    }
    8686
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r13204 r13206  
    421421            Collections.sort(vtTimezones);
    422422
    423             JosmComboBox<String> cbTimezones = new JosmComboBox<>(vtTimezones.toArray(new String[vtTimezones.size()]));
     423            JosmComboBox<String> cbTimezones = new JosmComboBox<>(vtTimezones.toArray(new String[0]));
    424424
    425425            String tzId = Config.getPref().get("geoimage.timezoneid", "");
     
    573573        panelCb.add(new JLabel(tr("GPX track: ")));
    574574
    575         cbGpx = new JosmComboBox<>(gpxLst.toArray(new GpxDataWrapper[gpxLst.size()]));
     575        cbGpx = new JosmComboBox<>(gpxLst.toArray(new GpxDataWrapper[0]));
    576576        if (defaultItem != null) {
    577577            cbGpx.setSelectedItem(defaultItem);
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r12671 r13206  
    349349        entries.add(new LayerListPopup.InfoAction(this));
    350350
    351         return entries.toArray(new Action[entries.size()]);
     351        return entries.toArray(new Action[0]);
    352352
    353353    }
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackAction.java

    r13130 r13206  
    124124            return null;
    125125        }
    126         return AbstractMergeAction.askTargetLayer(targetLayers.toArray(new AbstractTileSourceLayer[targetLayers.size()]),
     126        return AbstractMergeAction.askTargetLayer(targetLayers.toArray(new AbstractTileSourceLayer[0]),
    127127                tr("Please select the imagery layer."),
    128128                tr("Select imagery layer"),
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r12987 r13206  
    10331033        }
    10341034
    1035         return createColorLut(0, colorList.toArray(new Color[ colorList.size() ]));
     1035        return createColorLut(0, colorList.toArray(new Color[0]));
    10361036    }
    10371037
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r13130 r13206  
    240240        components.add(SeparatorLayerAction.INSTANCE);
    241241        components.add(new LayerListPopup.InfoAction(this));
    242         return components.toArray(new Action[components.size()]);
     242        return components.toArray(new Action[0]);
    243243    }
    244244
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java

    r12620 r13206  
    7676                tree.updateTree(wms);
    7777                List<String> wmsFormats = wms.getFormats();
    78                 formats.setModel(new DefaultComboBoxModel<>(wmsFormats.toArray(new String[wmsFormats.size()])));
     78                formats.setModel(new DefaultComboBoxModel<>(wmsFormats.toArray(new String[0])));
    7979                formats.setSelectedItem(wms.getPreferredFormats());
    8080            } catch (MalformedURLException ex1) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/CodeProjectionChoice.java

    r11017 r13206  
    9292            filter.getDocument().addDocumentListener(this);
    9393
    94             selectionList = new JList<>(data.toArray(new String[data.size()]));
     94            selectionList = new JList<>(data.toArray(new String[0]));
    9595            selectionList.setModel(model);
    9696            JScrollPane scroll = new JScrollPane(selectionList);
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java

    r13182 r13206  
    358358    public ProjectionPreference() {
    359359        this.projectionCombo = new JosmComboBox<>(
    360             projectionChoices.toArray(new ProjectionChoice[projectionChoices.size()]));
     360            projectionChoices.toArray(new ProjectionChoice[0]));
    361361        this.coordinatesCombo = new JosmComboBox<>(
    362362                CoordinateFormatManager.getCoordinateFormats().toArray(new ICoordinateFormat[0]));
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/UTMProjectionChoice.java

    r13167 r13206  
    4242     */
    4343    public UTMProjectionChoice() {
    44         super(tr("UTM"), /* NO-ICON */ "core:utm", cbEntries.toArray(new String[cbEntries.size()]), tr("UTM Zone"));
     44        super(tr("UTM"), /* NO-ICON */ "core:utm", cbEntries.toArray(new String[0]), tr("UTM Zone"));
    4545    }
    4646
     
    118118            }
    119119        }
    120         return projections.toArray(new String[projections.size()]);
     120        return projections.toArray(new String[0]);
    121121    }
    122122
     
    144144
    145145        if (args != null) {
    146             String[] array = args.toArray(new String[args.size()]);
     146            String[] array = args.toArray(new String[0]);
    147147
    148148            if (array.length > 1) {
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Check.java

    r12902 r13206  
    8181        allowedStates.add(QuadStateCheckBox.State.UNSET);
    8282        check = new QuadStateCheckBox(locale_text, initialState,
    83                 allowedStates.toArray(new QuadStateCheckBox.State[allowedStates.size()]));
     83                allowedStates.toArray(new QuadStateCheckBox.State[0]));
    8484        check.setPropertyText(key);
    8585        check.setState(check.getState()); // to update the tooltip text
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

    r12846 r13206  
    344344            result.add(item.toString());
    345345        }
    346         return result.toArray(new String[result.size()]);
     346        return result.toArray(new String[0]);
    347347    }
    348348
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java

    r12846 r13206  
    107107        } else {
    108108            // the objects have different values
    109             JosmComboBox<String> comboBox = new JosmComboBox<>(usage.values.toArray(new String[usage.values.size()]));
     109            JosmComboBox<String> comboBox = new JosmComboBox<>(usage.values.toArray(new String[0]));
    110110            comboBox.setEditable(true);
    111111            comboBox.setEditor(textField);
  • trunk/src/org/openstreetmap/josm/gui/widgets/NativeFileChooser.java

    r11017 r13206  
    5656        // https://bugs.openjdk.java.net/browse/JDK-4811090 : Extend awt filedialog
    5757        // https://bugs.openjdk.java.net/browse/JDK-6192906 : Add more features to java.awt.FileDialog
    58         return fileFilters.toArray(new FileFilter[fileFilters.size()]);
     58        return fileFilters.toArray(new FileFilter[0]);
    5959    }
    6060
  • trunk/src/org/openstreetmap/josm/tools/template_engine/TemplateParser.java

    r13003 r13206  
    6161                templateEntry = parseVariable();
    6262            } else if (endTokens.contains(token.getType()))
    63                 return CompoundTemplateEntry.fromArray(entries.toArray(new TemplateEntry[entries.size()]));
     63                return CompoundTemplateEntry.fromArray(entries.toArray(new TemplateEntry[0]));
    6464            else if (token.getType() == TokenType.TEXT) {
    6565                tokenizer.nextToken();
Note: See TracChangeset for help on using the changeset viewer.