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

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

Location:
trunk/src/org/openstreetmap/josm/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java

    r10627 r11553  
    1818import java.util.Locale;
    1919import java.util.Map;
     20import java.util.Optional;
    2021import java.util.TreeMap;
    2122import java.util.jar.Attributes;
     
    199200        Attributes attr = manifest.getMainAttributes();
    200201        className = attr.getValue("Plugin-Class");
    201         String s = attr.getValue(lang+"Plugin-Link");
    202         if (s == null) {
    203             s = attr.getValue("Plugin-Link");
    204         }
     202        String s = Optional.ofNullable(attr.getValue(lang+"Plugin-Link")).orElseGet(() -> attr.getValue("Plugin-Link"));
    205203        if (s != null && !Utils.isValidUrl(s)) {
    206204            Main.info(tr("Invalid URL ''{0}'' in plugin {1}", s, name));
  • trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java

    r10952 r11553  
    2222import java.util.LinkedList;
    2323import java.util.List;
     24import java.util.Optional;
    2425import java.util.Set;
    2526
     
    5455
    5556    protected final void init(Collection<String> sites, boolean displayErrMsg) {
    56         this.sites = sites;
    57         if (sites == null) {
    58             this.sites = Collections.emptySet();
    59         }
     57        this.sites = Optional.ofNullable(sites).orElseGet(Collections::emptySet);
    6058        this.availablePlugins = new LinkedList<>();
    6159        this.displayErrMsg = displayErrMsg;
Note: See TracChangeset for help on using the changeset viewer.