1
2
3
4
5
6 package cz.cuni.amis.pogamut.ut2004.communication.worldview.map;
7
8 import cz.cuni.amis.pogamut.unreal.communication.worldview.map.IUnrealWaylink;
9 import java.io.Serializable;
10
11 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.NavPointNeighbourLink;
12
13
14
15
16
17
18 public class Waylink implements IUnrealWaylink {
19 private String startId;
20 private String endId;
21 private int flags;
22
23 private Waypoint start;
24 private Waypoint end;
25
26 public Waylink(Waypoint start, NavPointNeighbourLink edge) {
27 this.startId = edge.getFromNavPoint().getId().getStringId();
28 this.endId = edge.getToNavPoint().getId().getStringId();
29
30 this.start = start;
31
32 this.flags = edge.getFlags();
33 }
34
35 protected void setEnd(Waypoint end) {
36 this.end = end;
37 }
38
39 public String getEndId() {
40 return endId;
41 }
42
43 public int getFlags() {
44 return flags;
45 }
46
47 public Waypoint getStart() {
48 return start;
49 }
50
51 public Waypoint getEnd() {
52 return end;
53 }
54
55 @Override
56 public boolean equals(Object b) {
57 if (b == null)
58 return false;
59 if((b == null) || (b.getClass() != this.getClass()))
60 return false;
61
62 Waylink wayB = (Waylink) b;
63
64 if (this.getFlags() != wayB.getFlags())
65 return false;
66
67 if (this.startId.equals(wayB.startId) && this.endId.equals(wayB.endId))
68 return true;
69
70 if (this.startId.equals(wayB.endId) && this.endId.equals(wayB.startId))
71 return true;
72
73 return false;
74 }
75
76 @Override
77 public int hashCode() {
78 int hash = 5;
79 hash = 83 * hash + (this.startId != null ? this.startId.hashCode() : 0);
80 hash = 83 * hash + (this.endId != null ? this.endId.hashCode() : 0);
81 hash = 83 * hash + this.flags;
82 return hash;
83 }
84 }