Ignore:
Timestamp:
2017-02-12T16:32:18+01:00 (7 years ago)
Author:
Don-vip
Message:

refactor handling of null values - use Java 8 Optional where possible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java

    r11374 r11553  
    99import java.util.List;
    1010import java.util.Objects;
     11import java.util.Optional;
    1112
    1213import javax.swing.Icon;
     
    169170        Collection<OsmPrimitive> prims = new HashSet<>();
    170171        for (PrimitiveData d : data) {
    171             OsmPrimitive osm = getAffectedDataSet().getPrimitiveById(d);
    172             if (osm == null)
    173                 throw new JosmRuntimeException("No primitive found for " + d);
    174             prims.add(osm);
     172            prims.add(Optional.ofNullable(getAffectedDataSet().getPrimitiveById(d)).orElseThrow(
     173                    () -> new JosmRuntimeException("No primitive found for " + d)));
    175174        }
    176175        return prims;
Note: See TracChangeset for help on using the changeset viewer.