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/gui/mappaint/styleelement/LineElement.java

    r11452 r11553  
    66import java.util.Arrays;
    77import java.util.Objects;
     8import java.util.Optional;
    89
    910import org.openstreetmap.josm.Main;
     
    357358                if (casingWidth == null)
    358359                    return null;
    359                 width = getWidth(c, WIDTH, getWidth(cDef, WIDTH, null));
    360                 if (width == null) {
    361                     width = 0f;
    362                 }
    363                 width += 2 * casingWidth;
     360                width = Optional.ofNullable(getWidth(c, WIDTH, getWidth(cDef, WIDTH, null))).orElse(0f) + 2 * casingWidth;
    364361                break;
    365362            case LEFT_CASING:
     
    378375
    379376            /* if we have a "width" tag, try use it */
    380             String widthTag = env.osm.get("width");
    381             if (widthTag == null) {
    382                 widthTag = env.osm.get("est_width");
    383             }
     377            String widthTag = Optional.ofNullable(env.osm.get("width")).orElseGet(() -> env.osm.get("est_width"));
    384378            if (widthTag != null) {
    385379                try {
Note: See TracChangeset for help on using the changeset viewer.