1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
2 | // |
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
4 | // you may not use this file except in compliance with the License. |
---|
5 | // You may obtain a copy of the License at |
---|
6 | // |
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
8 | // |
---|
9 | // Unless required by applicable law or agreed to in writing, software |
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
12 | // See the License for the specific language governing permissions and |
---|
13 | // limitations under the License. |
---|
14 | |
---|
15 | package de.ugoe.cs.autoquest.eventcore; |
---|
16 | |
---|
17 | /** |
---|
18 | * <p> |
---|
19 | * A simple event type that is identified by a string. |
---|
20 | * </p> |
---|
21 | * |
---|
22 | * @version $Revision: $ $Date: Aug 16, 2012$ |
---|
23 | * @author 2012, last modified by $Author: sherbold$ |
---|
24 | */ |
---|
25 | public class StringEventType implements IEventType { |
---|
26 | |
---|
27 | /** |
---|
28 | * <p> |
---|
29 | * Id for object serialization. |
---|
30 | * </p> |
---|
31 | */ |
---|
32 | private static final long serialVersionUID = 1L; |
---|
33 | |
---|
34 | /** |
---|
35 | * <p> |
---|
36 | * String that identifies the event type. |
---|
37 | * </p> |
---|
38 | */ |
---|
39 | private String str; |
---|
40 | |
---|
41 | /** |
---|
42 | * <p> |
---|
43 | * Constructor. Creates a new StringEventType. str must not be null. |
---|
44 | * </p> |
---|
45 | * |
---|
46 | * @param str |
---|
47 | * string that identifies the event type |
---|
48 | * @throws IllegalArgumentException |
---|
49 | * thrown if str is null |
---|
50 | */ |
---|
51 | public StringEventType(String str) throws IllegalArgumentException { |
---|
52 | if (str == null) { |
---|
53 | throw new IllegalArgumentException("str must not be null"); |
---|
54 | } |
---|
55 | this.str = str; |
---|
56 | } |
---|
57 | |
---|
58 | /* |
---|
59 | * (non-Javadoc) |
---|
60 | * |
---|
61 | * @see de.ugoe.cs.autoquest.eventcore.IEventType#getName() |
---|
62 | */ |
---|
63 | @Override |
---|
64 | public String getName() { |
---|
65 | return "StringEventType"; |
---|
66 | } |
---|
67 | |
---|
68 | /* |
---|
69 | * (non-Javadoc) |
---|
70 | * |
---|
71 | * @see java.lang.Object#toString() |
---|
72 | */ |
---|
73 | @Override |
---|
74 | public String toString() { |
---|
75 | return str; |
---|
76 | } |
---|
77 | |
---|
78 | /* |
---|
79 | * (non-Javadoc) |
---|
80 | * |
---|
81 | * @see java.lang.Object#hashCode() |
---|
82 | */ |
---|
83 | @Override |
---|
84 | public int hashCode() { |
---|
85 | return str.hashCode(); |
---|
86 | } |
---|
87 | |
---|
88 | /* |
---|
89 | * (non-Javadoc) |
---|
90 | * |
---|
91 | * @see java.lang.Object#equals(java.lang.Object) |
---|
92 | */ |
---|
93 | @Override |
---|
94 | public boolean equals(Object other) { |
---|
95 | if (other == this) { |
---|
96 | return true; |
---|
97 | } |
---|
98 | if (other instanceof StringEventType) { |
---|
99 | return str.equals(((StringEventType) other).str); |
---|
100 | } |
---|
101 | return false; |
---|
102 | } |
---|
103 | } |
---|