1 package org.djutils.event;
2
3 import java.io.Serializable;
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 public class Event implements EventInterface
21 {
22
23 private static final long serialVersionUID = 20140826L;
24
25
26 private final EventType type;
27
28
29 private final Serializable content;
30
31
32 private final Serializable sourceId;
33
34
35
36
37
38
39
40 public Event(final EventType type, final Serializable sourceId, final Serializable content)
41 {
42 this.type = type;
43 this.sourceId = sourceId;
44 this.content = content;
45 }
46
47
48 @Override
49 public final Serializable getSourceId()
50 {
51 return this.sourceId;
52 }
53
54
55 @Override
56 public final Serializable getContent()
57 {
58 return this.content;
59 }
60
61
62 @Override
63 public final EventType getType()
64 {
65 return this.type;
66 }
67
68
69 @Override
70 public String toString()
71 {
72 return "[" + this.getClass().getName() + ";" + this.getType() + ";" + this.getSourceId() + ";" + this.getContent()
73 + "]";
74 }
75
76
77 @Override
78 public int hashCode()
79 {
80 final int prime = 31;
81 int result = 1;
82 result = prime * result + ((this.content == null) ? 0 : this.content.hashCode());
83 result = prime * result + ((this.sourceId == null) ? 0 : this.sourceId.hashCode());
84 result = prime * result + ((this.type == null) ? 0 : this.type.hashCode());
85 return result;
86 }
87
88
89 @Override
90 @SuppressWarnings("checkstyle:needbraces")
91 public boolean equals(final Object obj)
92 {
93 if (this == obj)
94 return true;
95 if (obj == null)
96 return false;
97 if (getClass() != obj.getClass())
98 return false;
99 Event="../../../org/djutils/event/Event.html#Event">Event other = (Event) obj;
100 if (this.content == null)
101 {
102 if (other.content != null)
103 return false;
104 }
105 else if (!this.content.equals(other.content))
106 return false;
107 if (this.sourceId == null)
108 {
109 if (other.sourceId != null)
110 return false;
111 }
112 else if (!this.sourceId.equals(other.sourceId))
113 return false;
114 if (this.type == null)
115 {
116 if (other.type != null)
117 return false;
118 }
119 else if (!this.type.equals(other.type))
120 return false;
121 return true;
122 }
123
124 }