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

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