source: josm/trunk/src/org/openstreetmap/josm/data/osm/SimplePrimitiveId.java@ 4153

Last change on this file since 4153 was 3115, checked in by Gubaer, 14 years ago

added Serializable on SimplePrimitiveId, going to need for DnD in a plugin

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import java.io.Serializable;
5
6public class SimplePrimitiveId implements PrimitiveId, Serializable {
7 private final long id;
8 private final OsmPrimitiveType type;
9
10 public SimplePrimitiveId(long id, OsmPrimitiveType type) {
11 this.id = id;
12 this.type = type;
13 }
14
15 public OsmPrimitiveType getType() {
16 return type;
17 }
18
19 public long getUniqueId() {
20 return id;
21 }
22
23 public boolean isNew() {
24 return id <= 0;
25 }
26
27 @Override
28 public int hashCode() {
29 final int prime = 31;
30 int result = 1;
31 result = prime * result + (int) (id ^ (id >>> 32));
32 result = prime * result + ((type == null) ? 0 : type.hashCode());
33 return result;
34 }
35
36 @Override
37 public boolean equals(Object obj) {
38 if (this == obj)
39 return true;
40 if (obj == null)
41 return false;
42 if (getClass() != obj.getClass())
43 return false;
44 SimplePrimitiveId other = (SimplePrimitiveId) obj;
45 if (id != other.id)
46 return false;
47 if (type == null) {
48 if (other.type != null)
49 return false;
50 } else if (!type.equals(other.type))
51 return false;
52 return true;
53 }
54
55 @Override
56 public String toString() {
57 return type + " " + id;
58 }
59}
Note: See TracBrowser for help on using the repository browser.