Changeset 35841 in osm for applications/editors


Ignore:
Timestamp:
2021-11-01T08:59:07+01:00 (3 years ago)
Author:
GerdP
Message:

fix some checkstyle and sonarlint issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java

    r35833 r35841  
    222222        }
    223223        // both nodes aren't allowed to be consecutive
    224                 if ((splitWay == null || splitWay.getNodesCount() == 2)
    225                                 && (nodeIndex1 == nodeIndex2 + 1 || nodeIndex2 == nodeIndex1 + 1 ||
    226                                 // minus 2 because we've a circular way where
    227                                 // the penultimate node is the last unique one
    228                                                 (nodeIndex1 == 0 && nodeIndex2 == selectedWay.getNodesCount() - 2)
    229                                                 || (nodeIndex2 == 0 && nodeIndex1 == selectedWay.getNodesCount() - 2))) {
     224        if ((splitWay == null || splitWay.getNodesCount() == 2)
     225                && (nodeIndex1 == nodeIndex2 + 1 || nodeIndex2 == nodeIndex1 + 1 ||
     226                // minus 2 because we've a circular way where
     227                // the penultimate node is the last unique one
     228                        (nodeIndex1 == 0 && nodeIndex2 == selectedWay.getNodesCount() - 2)
     229                        || (nodeIndex2 == 0 && nodeIndex1 == selectedWay.getNodesCount() - 2))) {
    230230            showWarningNotification(
    231231                    tr("The selected nodes can not be consecutive nodes in the object."));
    232232            return;
    233233        }
    234 
     234        splitWayChecked(selectedNodes, selectedWay, splitWay);
     235    }
     236
     237    private void splitWayChecked(List<Node> selectedNodes, Way selectedWay, Way splitWay) {
    235238        List<List<Node>> wayChunks = SplitWayCommand.buildSplitChunks(selectedWay, selectedNodes);
    236239        if (wayChunks != null) {
     
    416419                for (int i = 0; i < outerRing.ways.size() && (firstIndex == -1 || lastIndex == -1); i++) {
    417420                    Way w = outerRing.ways.get(i);
    418                     Boolean reversed = outerRing.reversed.get(i);
     421                    boolean reversed = outerRing.reversed.get(i);
    419422
    420423                    Node cStartNode = reversed ? w.lastNode() : w.firstNode();
     
    522525        Set<Way> mpWays = mpRelation.getMembers().stream()
    523526            .filter(RelationMember::isWay)
    524             .collect(Collectors.mapping(RelationMember::getWay, Collectors.toSet()));
     527            .map(RelationMember::getWay)
     528            .collect(Collectors.toSet());
    525529
    526530        List<SplitWayCommand> splitCmds = new ArrayList<>();
     
    555559     * @return true if the selection is usable
    556560     */
    557     private boolean checkSelection(Collection<? extends OsmPrimitive> selection) {
     561    private static boolean checkSelection(Collection<? extends OsmPrimitive> selection) {
    558562        int node = 0;
    559563        int ways = 0;
Note: See TracChangeset for help on using the changeset viewer.