Ignore:
Timestamp:
2017-04-10T00:14:42+02:00 (7 years ago)
Author:
Don-vip
Message:

findbugs - EI_EXPOSE_REP2 + javadoc

File:
1 edited

Legend:

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

    r11608 r11878  
    1313import java.util.Objects;
    1414
     15import org.openstreetmap.josm.Main;
    1516import org.openstreetmap.josm.data.osm.Changeset;
    1617import org.openstreetmap.josm.data.osm.Node;
    1718import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1819import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     20import org.openstreetmap.josm.data.osm.PrimitiveData;
    1921import org.openstreetmap.josm.data.osm.PrimitiveId;
    2022import org.openstreetmap.josm.data.osm.Relation;
     
    2426import org.openstreetmap.josm.data.osm.Way;
    2527import org.openstreetmap.josm.tools.CheckParameterUtil;
     28import org.openstreetmap.josm.tools.date.DateUtils;
    2629
    2730/**
     
    8588        this.user = user;
    8689        this.changesetId = changesetId;
    87         this.timestamp = timestamp;
    88         tags = new HashMap<>();
     90        this.timestamp = DateUtils.cloneDate(timestamp);
     91        this.tags = new HashMap<>();
    8992    }
    9093
     
    159162     */
    160163    public Date getTimestamp() {
    161         return timestamp;
     164        return DateUtils.cloneDate(timestamp);
    162165    }
    163166
     
    170173    }
    171174
     175    /**
     176     * Checks that value is positive.
     177     * @param value value to check
     178     * @param name parameter name for error message
     179     * @throws IllegalArgumentException if {@code value <= 0}
     180     */
    172181    protected final void ensurePositiveLong(long value, String name) {
    173182        if (value <= 0) {
     
    176185    }
    177186
     187    /**
     188     * Determines if this history matches given id and version.
     189     * @param id Primitive identifier
     190     * @param version Primitive version
     191     * @return {@code true} if this history matches given id and version
     192     */
    178193    public boolean matches(long id, long version) {
    179194        return this.id == id && this.version == version;
    180195    }
    181196
     197    /**
     198     * Determines if this history matches given id.
     199     * @param id Primitive identifier
     200     * @return {@code true} if this history matches given id
     201     */
    182202    public boolean matches(long id) {
    183203        return this.id == id;
     
    325345    }
    326346
     347    /**
     348     * Fills the attributes common to all primitives with values from this history.
     349     * @param data primitive data to fill
     350     */
     351    protected void fillPrimitiveCommonData(PrimitiveData data) {
     352        data.setUser(user);
     353        try {
     354            data.setVisible(visible);
     355        } catch (IllegalStateException e) {
     356            Main.error(e, "Cannot change visibility for "+data+':');
     357        }
     358        data.setTimestamp(timestamp);
     359        data.setKeys(tags);
     360        data.setOsmId(id, (int) version);
     361    }
     362
    327363    @Override
    328364    public int hashCode() {
     
    335371        if (obj == null || getClass() != obj.getClass()) return false;
    336372        HistoryOsmPrimitive that = (HistoryOsmPrimitive) obj;
    337         return id == that.id &&
    338                 version == that.version;
     373        return id == that.id && version == that.version;
    339374    }
    340375
Note: See TracChangeset for help on using the changeset viewer.