Changeset 6229 in josm for trunk


Ignore:
Timestamp:
2013-09-11T00:32:31+02:00 (11 years ago)
Author:
Don-vip
Message:

Sonar - Avoid throwing NullPointerException

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSource.java

    r2986 r6229  
    33
    44import org.openstreetmap.josm.data.Bounds;
     5import org.openstreetmap.josm.tools.CheckParameterUtil;
    56
     7/**
     8 * A data source, defined by bounds and textual description for the origin.
     9 * @since 247
     10 */
    611public class DataSource {
     12    /**
     13     * The bounds of this data source
     14     */
    715    public final Bounds bounds;
     16    /**
     17     * The textual description of the origin (example: "OpenStreetMap Server")
     18     */
    819    public final String origin;
    920
     21    /**
     22     * Constructs a new {@code DataSource}.
     23     * @param bounds The bounds of this data source
     24     * @param origin The textual description of the origin (example: "OpenStreetMap Server")
     25     * @throws IllegalArgumentException if bounds is {@code null}
     26     */
    1027    public DataSource(Bounds bounds, String origin) {
     28        CheckParameterUtil.ensureParameterNotNull(bounds, "bounds");
    1129        this.bounds = bounds;
    1230        this.origin = origin;
    13         if (bounds == null)
    14             throw new NullPointerException();
    1531    }
    1632}
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r5949 r6229  
    173173
    174174        private void setValue(Entry entry, String fieldName, String value) throws SAXException {
    175             if (entry == null) {
    176                 throw new NullPointerException("entry cannot be null");
    177             }
     175            CheckParameterUtil.ensureParameterNotNull(entry, "entry");
    178176            if (fieldName.equals("class") || fieldName.equals("default") || fieldName.equals("throw") || fieldName.equals("new") || fieldName.equals("null")) {
    179177                fieldName += "_";
Note: See TracChangeset for help on using the changeset viewer.