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

fix #16176 - NPE

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.