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

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

Location:
trunk/src/org/openstreetmap/josm/gui/history
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r11397 r11553  
    309309            throw new IllegalArgumentException(
    310310                    tr("Failed to set reference. Reference ID {0} does not match history ID {1}.", reference.getId(), history.getId()));
    311         HistoryOsmPrimitive primitive = history.getByVersion(reference.getVersion());
    312         if (primitive == null)
     311        if (history.getByVersion(reference.getVersion()) == null)
    313312            throw new IllegalArgumentException(
    314313                    tr("Failed to set reference. Reference version {0} not available in history.", reference.getVersion()));
     
    340339            throw new IllegalArgumentException(
    341340                    tr("Failed to set reference. Reference ID {0} does not match history ID {1}.", current.getId(), history.getId()));
    342         HistoryOsmPrimitive primitive = history.getByVersion(current.getVersion());
    343         if (primitive == null)
     341        if (history.getByVersion(current.getVersion()) == null)
    344342            throw new IllegalArgumentException(
    345343                    tr("Failed to set current primitive. Current version {0} not available in history.", current.getVersion()));
     
    389387    /**
    390388     * Returns true if <code>primitive</code> is the latest primitive
    391      * representing the version currently edited in the current data
    392      * layer.
     389     * representing the version currently edited in the current data layer.
    393390     *
    394391     * @param primitive the primitive to check
     
    396393     */
    397394    public boolean isLatest(HistoryOsmPrimitive primitive) {
    398         if (primitive == null)
    399             return false;
    400         return primitive == latest;
     395        return primitive != null && primitive == latest;
    401396    }
    402397
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java

    r11087 r11553  
    135135        CheckParameterUtil.ensureParameterNotNull(primitives, "primitives");
    136136        for (OsmPrimitive primitive: primitives) {
    137             if (primitive == null) {
    138                 continue;
     137            if (primitive != null) {
     138                add(primitive);
    139139            }
    140             add(primitive);
    141140        }
    142141        return this;
Note: See TracChangeset for help on using the changeset viewer.