Last change
on this file since 609 was
553,
checked in by sherbold, 12 years ago
|
- countless adaptations throughout nearly all components to remove errors introduced due to the refactoring of the event core
- added StringEventType? as a simple-to-use event type instead of DummyEventType?
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.9 KB
|
Line | |
---|
1 | |
---|
2 | package de.ugoe.cs.quest.eventcore; |
---|
3 | |
---|
4 | import java.security.InvalidParameterException; |
---|
5 | |
---|
6 | /** |
---|
7 | * <p> |
---|
8 | * A simple event type that is identified by a string. |
---|
9 | * </p> |
---|
10 | * |
---|
11 | * @version $Revision: $ $Date: Aug 16, 2012$ |
---|
12 | * @author 2012, last modified by $Author: sherbold$ |
---|
13 | */ |
---|
14 | public class StringEventType implements IEventType { |
---|
15 | |
---|
16 | /** |
---|
17 | * <p> |
---|
18 | * Id for object serialization. |
---|
19 | * </p> |
---|
20 | */ |
---|
21 | private static final long serialVersionUID = 1L; |
---|
22 | |
---|
23 | /** |
---|
24 | * <p> |
---|
25 | * String that identifies the event type. |
---|
26 | * </p> |
---|
27 | */ |
---|
28 | private String str; |
---|
29 | |
---|
30 | /** |
---|
31 | * <p> |
---|
32 | * Constructor. Creates a new StringEventType. str must not be null. |
---|
33 | * </p> |
---|
34 | * |
---|
35 | * @param str |
---|
36 | * string that identifies the event type |
---|
37 | * @throws InvalidParameterException |
---|
38 | * thrown if str is null |
---|
39 | */ |
---|
40 | public StringEventType(String str) throws InvalidParameterException { |
---|
41 | if (str == null) { |
---|
42 | throw new InvalidParameterException("str must not be null"); |
---|
43 | } |
---|
44 | this.str = str; |
---|
45 | } |
---|
46 | |
---|
47 | /* |
---|
48 | * (non-Javadoc) |
---|
49 | * |
---|
50 | * @see de.ugoe.cs.quest.eventcore.IEventType#getName() |
---|
51 | */ |
---|
52 | @Override |
---|
53 | public String getName() { |
---|
54 | return "StringEventType"; |
---|
55 | } |
---|
56 | |
---|
57 | /* |
---|
58 | * (non-Javadoc) |
---|
59 | * |
---|
60 | * @see java.lang.Object#toString() |
---|
61 | */ |
---|
62 | @Override |
---|
63 | public String toString() { |
---|
64 | return str; |
---|
65 | } |
---|
66 | |
---|
67 | /* |
---|
68 | * (non-Javadoc) |
---|
69 | * |
---|
70 | * @see java.lang.Object#hashCode() |
---|
71 | */ |
---|
72 | @Override |
---|
73 | public int hashCode() { |
---|
74 | return str.hashCode(); |
---|
75 | } |
---|
76 | |
---|
77 | /* |
---|
78 | * (non-Javadoc) |
---|
79 | * |
---|
80 | * @see java.lang.Object#equals(java.lang.Object) |
---|
81 | */ |
---|
82 | @Override |
---|
83 | public boolean equals(Object other) { |
---|
84 | if (other == this) { |
---|
85 | return true; |
---|
86 | } |
---|
87 | if (other instanceof StringEventType) { |
---|
88 | return str.equals(((StringEventType) other).str); |
---|
89 | } |
---|
90 | return false; |
---|
91 | } |
---|
92 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.