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/preferences/ToolbarPreferences.java

    r11344 r11553  
    2727import java.util.List;
    2828import java.util.Map;
     29import java.util.Optional;
    2930import java.util.concurrent.ConcurrentHashMap;
    3031
     
    160161            if (ico != null)
    161162                return ico;
    162             Object o = action.getValue(Action.LARGE_ICON_KEY);
    163             if (o == null)
    164                 o = action.getValue(Action.SMALL_ICON);
    165             return (Icon) o;
     163            return (Icon) Optional.ofNullable(action.getValue(Action.LARGE_ICON_KEY)).orElseGet(() -> action.getValue(Action.SMALL_ICON));
    166164        }
    167165
     
    11931191        }
    11941192
    1195         String tt = action.getDisplayTooltip();
    1196         if (tt == null) {
    1197             tt = "";
    1198         }
     1193        String tt = Optional.ofNullable(action.getDisplayTooltip()).orElse("");
    11991194
    12001195        if (sc == null || paramCode != 0) {
    1201             String name = (String) action.getAction().getValue("toolbar");
    1202             if (name == null) {
    1203                 name = action.getDisplayName();
    1204             }
     1196            String name = Optional.ofNullable((String) action.getAction().getValue("toolbar")).orElseGet(action::getDisplayName);
    12051197            if (paramCode != 0) {
    12061198                name = name+paramCode;
Note: See TracChangeset for help on using the changeset viewer.