Ignore:
Timestamp:
2018-04-10T19:02:58+02:00 (20 months ago)
Author:
Don-vip
Message:

fix #16176 - NPE

Location:
trunk/src/org/openstreetmap/josm/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java

    r12986 r13611  
    33
    44import java.util.Arrays;
     5import java.util.Collection;
    56import java.util.HashSet;
    67import java.util.Locale;
    78import java.util.Map;
     9import java.util.Objects;
    810import java.util.Set;
    911
     
    153155        return layer1;
    154156    }
     157
     158    /**
     159     * Determines if the given collection contains primitives, and that none of them belong to a locked layer.
     160     * @param collection collection of OSM primitives
     161     * @return {@code true} if the given collection is not empty and does not contain any primitive in a locked layer.
     162     * @since 13611
     163     */
     164    public static boolean isOsmCollectionEditable(Collection<? extends OsmPrimitive> collection) {
     165        return collection != null && !collection.isEmpty()
     166            && collection.stream().map(OsmPrimitive::getDataSet).filter(Objects::nonNull).noneMatch(DataSet::isLocked);
     167    }
    155168}
  • trunk/src/org/openstreetmap/josm/data/validation/TestError.java

    r13489 r13611  
    1212
    1313import org.openstreetmap.josm.command.Command;
    14 import org.openstreetmap.josm.data.osm.DataSet;
    1514import org.openstreetmap.josm.data.osm.Node;
    1615import org.openstreetmap.josm.data.osm.OsmPrimitive;
     16import org.openstreetmap.josm.data.osm.OsmUtils;
    1717import org.openstreetmap.josm.data.osm.Relation;
    1818import org.openstreetmap.josm.data.osm.Way;
     
    360360    public boolean isFixable() {
    361361        return (fixingCommand != null || ((tester != null) && tester.isFixable(this)))
    362                 && primitives.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked);
     362                && OsmUtils.isOsmCollectionEditable(primitives);
    363363    }
    364364
Note: See TracChangeset for help on using the changeset viewer.