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

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

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r11023 r11553  
    99import java.util.List;
    1010import java.util.Objects;
     11import java.util.Optional;
    1112import java.util.function.Predicate;
    1213
     
    149150     */
    150151    public void startTest(ProgressMonitor progressMonitor) {
    151         if (progressMonitor == null) {
    152             this.progressMonitor = NullProgressMonitor.INSTANCE;
    153         } else {
    154             this.progressMonitor = progressMonitor;
    155         }
     152        this.progressMonitor = Optional.ofNullable(progressMonitor).orElse(NullProgressMonitor.INSTANCE);
    156153        String startMessage = tr("Running test {0}", name);
    157154        this.progressMonitor.beginTask(startMessage);
  • trunk/src/org/openstreetmap/josm/data/validation/util/MultipleNameVisitor.java

    r10137 r11553  
    55
    66import java.util.Collection;
     7import java.util.Optional;
    78
    89import javax.swing.Icon;
     
    4243        multipleClassname = null;
    4344        for (OsmPrimitive osm : data) {
    44             String name = osm.get("name");
    45             if (name == null) {
    46                 name = osm.get("ref");
    47             }
     45            String name = Optional.ofNullable(osm.get("name")).orElseGet(() -> osm.get("ref"));
    4846            if (name != null && !name.isEmpty() && multipleName.length() <= MULTIPLE_NAME_MAX_LENGTH) {
    4947                if (multipleName.length() > 0) {
Note: See TracChangeset for help on using the changeset viewer.