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/io/NoteReader.java

    r11453 r11553  
    1010import java.util.List;
    1111import java.util.Locale;
     12import java.util.Optional;
    1213
    1314import javax.xml.parsers.ParserConfigurationException;
     
    110111                break;
    111112            case "comment":
    112                 String uidStr = attrs.getValue("uid");
    113                 if (uidStr == null) {
    114                     commentUid = 0;
    115                 } else {
    116                     commentUid = Long.parseLong(uidStr);
    117                 }
     113                commentUid = Long.parseLong(Optional.ofNullable(attrs.getValue("uid")).orElse("0"));
    118114                commentUsername = attrs.getValue("user");
    119115                noteAction = Action.valueOf(attrs.getValue("action").toUpperCase(Locale.ENGLISH));
    120116                commentCreateDate = DateUtils.fromString(attrs.getValue("timestamp"));
    121                 String isNew = attrs.getValue("is_new");
    122                 if (isNew == null) {
    123                     commentIsNew = false;
    124                 } else {
    125                     commentIsNew = Boolean.parseBoolean(isNew);
    126                 }
     117                commentIsNew = Boolean.parseBoolean(Optional.ofNullable(attrs.getValue("is_new")).orElse("false"));
    127118                break;
    128119            default: // Do nothing
Note: See TracChangeset for help on using the changeset viewer.