Ignore:
Timestamp:
2017-02-12T16:32:18+01:00 (9 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/io/NmeaReader.java

    r11374 r11553  
    1313import java.util.Collections;
    1414import java.util.Date;
     15import java.util.Optional;
    1516
    1617import org.openstreetmap.josm.Main;
     
    112113
    113114    private Date readTime(String p) {
    114         Date d = rmcTimeFmt.parse(p, new ParsePosition(0));
    115         if (d == null) {
    116             d = rmcTimeFmtStd.parse(p, new ParsePosition(0));
    117         }
     115        Date d = Optional.ofNullable(rmcTimeFmt.parse(p, new ParsePosition(0)))
     116                .orElseGet(() -> rmcTimeFmtStd.parse(p, new ParsePosition(0)));
    118117        if (d == null)
    119118            throw new JosmRuntimeException("Date is malformed");
Note: See TracChangeset for help on using the changeset viewer.