source: trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/StringEventType.java @ 766

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