Changeset 9881 in josm


Ignore:
Timestamp:
2016-02-25T01:51:43+01:00 (9 years ago)
Author:
Don-vip
Message:

remove unused code, add unit test

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java

    r8510 r9881  
    77import java.awt.event.ActionEvent;
    88import java.awt.event.KeyEvent;
    9 import java.text.MessageFormat;
    109import java.util.Collection;
    11 import java.util.Map;
    1210
    1311import org.openstreetmap.josm.Main;
    1412import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask;
    1513import org.openstreetmap.josm.data.osm.OsmPrimitive;
    16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1714import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    18 import org.openstreetmap.josm.tools.CheckParameterUtil;
    1915import org.openstreetmap.josm.tools.Shortcut;
    2016
     
    4743     */
    4844    public static void downloadReferrers(OsmDataLayer targetLayer, Collection<OsmPrimitive> children) {
    49         if (children == null || children.isEmpty()) return;
     45        if (children == null || children.isEmpty())
     46            return;
    5047        Main.worker.submit(new DownloadReferrersTask(targetLayer, children));
    51     }
    52 
    53     /**
    54      * Downloads the primitives referring to the primitives in <code>primitives</code>
    55      * into the target layer <code>targetLayer</code>.
    56      * Does nothing if primitives is null or empty.
    57      *
    58      * @param targetLayer the target layer. Must not be null.
    59      * @param children the collection of primitives, given as map of ids and types
    60      * @throws IllegalArgumentException if targetLayer is null
    61      */
    62     public static void downloadReferrers(OsmDataLayer targetLayer, Map<Long, OsmPrimitiveType> children) {
    63         if (children == null || children.isEmpty()) return;
    64         Main.worker.submit(new DownloadReferrersTask(targetLayer, children));
    65     }
    66 
    67     /**
    68      * Downloads the primitives referring to the primitive given by <code>id</code> and <code>type</code>.
    69      *
    70      * @param targetLayer the target layer. Must not be null.
    71      * @param id the primitive id. id &gt; 0 required.
    72      * @param type the primitive type. type != null required
    73      * @throws IllegalArgumentException if targetLayer is null
    74      * @throws IllegalArgumentException if id &lt;= 0
    75      * @throws IllegalArgumentException if type == null
    76      */
    77     public static void downloadReferrers(OsmDataLayer targetLayer, long id, OsmPrimitiveType type) {
    78         if (id <= 0)
    79             throw new IllegalArgumentException(MessageFormat.format("Id > 0 required, got {0}", id));
    80         CheckParameterUtil.ensureParameterNotNull(type, "type");
    81         Main.worker.submit(new DownloadReferrersTask(targetLayer, id, type));
    8248    }
    8349
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java

    r9241 r9881  
    7171        this.targetLayer = targetLayer;
    7272        parents = new DataSet();
    73     }
    74 
    75     /**
    76      * constructor
    77      *
    78      * @param targetLayer  the target layer for the downloaded primitives. Must not be null.
    79      * @param children  the collection of children for which parents are to be downloaded. Children
    80      * are specified by their id and  their type.
    81      */
    82     public DownloadReferrersTask(OsmDataLayer targetLayer, Map<Long, OsmPrimitiveType> children) {
    83         super("Download referrers", false /* don't ignore exception*/);
    84         CheckParameterUtil.ensureParameterNotNull(targetLayer, "targetLayer");
    85         canceled = false;
    86         this.children = new HashMap<>();
    87         if (children != null) {
    88             for (Entry<Long, OsmPrimitiveType> entry : children.entrySet()) {
    89                 if (entry.getKey() > 0 && entry.getValue() != null) {
    90                     children.put(entry.getKey(), entry.getValue());
    91                 }
    92             }
    93         }
    94         this.targetLayer = targetLayer;
    95         parents = new DataSet();
    96     }
    97 
    98     /**
    99      * constructor
    100      *
    101      * @param targetLayer  the target layer. Must not be null.
    102      * @param id the primitive id. id &gt; 0 required.
    103      * @param type the primitive type. type != null required
    104      * @throws IllegalArgumentException if id &lt;= 0
    105      * @throws IllegalArgumentException if type == null
    106      * @throws IllegalArgumentException if targetLayer == null
    107      */
    108     public DownloadReferrersTask(OsmDataLayer targetLayer, long id, OsmPrimitiveType type) {
    109         super("Download referrers", false /* don't ignore exception*/);
    110         CheckParameterUtil.ensureParameterNotNull(targetLayer, "targetLayer");
    111         if (id <= 0)
    112             throw new IllegalArgumentException(MessageFormat.format("Id > 0 required, got {0}", id));
    113         CheckParameterUtil.ensureParameterNotNull(type, "type");
    114         canceled = false;
    115         this.children = new HashMap<>();
    116         this.children.put(id, type);
    117         this.targetLayer = targetLayer;
    118         parents = new DataSet();
    119     }
    120 
    121     /**
    122      * constructor
    123      *
    124      * @param targetLayer the target layer. Must not be null.
    125      * @param primitiveId a PrimitiveId object.
    126      * @throws IllegalArgumentException if id &lt;= 0
    127      * @throws IllegalArgumentException if targetLayer == null
    128      */
    129     public DownloadReferrersTask(OsmDataLayer targetLayer, PrimitiveId primitiveId) {
    130         this(targetLayer,  primitiveId, null);
    13173    }
    13274
Note: See TracChangeset for help on using the changeset viewer.