source: trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/gui/ValueSelection.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:executable set to *
File size: 3.1 KB
Line 
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
15package de.ugoe.cs.autoquest.eventcore.gui;
16
17/**
18 * <p>
19 * Event type for selecting a value.
20 * </p>
21 *
22 * @version 1.0
23 * @author Patrick Harms
24 */
25public class ValueSelection<T> implements IInteraction {
26
27    /**
28     * <p>
29     * Id for object serialization.
30     * </p>
31     */
32    private static final long serialVersionUID = 1L;
33
34    /**
35     * <p>
36     * The selected value.
37     * </p>
38     */
39    private T selectedValue;
40
41    /**
42     * <p>
43     * Constructor. Creates a new ValueSelection.
44     * </p>
45     *
46     * @param selectedValue
47     *            the selected value
48     */
49    public ValueSelection(T selectedValue) {
50        this.selectedValue = selectedValue;
51    }
52
53    /*
54     * (non-Javadoc)
55     *
56     * @see de.harms.attef.userinteraction.Interaction#getName()
57     */
58    public String getName() {
59        return "ValueSelection";
60    }
61
62    /*
63     * (non-Javadoc)
64     *
65     * @see java.lang.Object#toString()
66     */
67    @Override
68    public String toString() {
69        return "select value";
70    }
71
72    /*
73     * (non-Javadoc)
74     *
75     * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
76     */
77    public boolean startsLogicalSequence() {
78        return false;
79    }
80
81    /*
82     * (non-Javadoc)
83     *
84     * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
85     */
86    public boolean finishesLogicalSequence() {
87        return false;
88    }
89
90    /**
91     * <p>
92     * Returns the selected value associated with this event.
93     * </p>
94     *
95     * @return the selectedValue
96     */
97    public T getSelectedValue() {
98        return selectedValue;
99    }
100
101    /*
102     * (non-Javadoc)
103     *
104     * @see java.lang.Object#equals(java.lang.Object)
105     */
106    @Override
107    public boolean equals(Object obj) {
108        if ((obj == null) || (!(obj instanceof ValueSelection<?>))) {
109            return false;
110        }
111
112        ValueSelection<?> otherValueSelection = (ValueSelection<?>) obj;
113
114        return ((otherValueSelection != null) && ((selectedValue == otherValueSelection.selectedValue) || ((selectedValue != null) && (selectedValue
115            .equals(otherValueSelection.selectedValue)))));
116    }
117
118    /*
119     * (non-Javadoc)
120     *
121     * @see java.lang.Object#hashCode()
122     */
123    @Override
124    public int hashCode() {
125        return selectedValue.hashCode();
126    }
127
128}
Note: See TracBrowser for help on using the repository browser.