1 |
|
---|
2 | package de.ugoe.cs.autoquest.eventcore.gui;
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * <p>
|
---|
6 | * Event type for selecting a value.
|
---|
7 | * </p>
|
---|
8 | *
|
---|
9 | * @version 1.0
|
---|
10 | * @author Patrick Harms
|
---|
11 | */
|
---|
12 | public class ValueSelection<T> implements IInteraction {
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * <p>
|
---|
16 | * Id for object serialization.
|
---|
17 | * </p>
|
---|
18 | */
|
---|
19 | private static final long serialVersionUID = 1L;
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * <p>
|
---|
23 | * The selected value.
|
---|
24 | * </p>
|
---|
25 | */
|
---|
26 | private T selectedValue;
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * <p>
|
---|
30 | * Constructor. Creates a new ValueSelection.
|
---|
31 | * </p>
|
---|
32 | *
|
---|
33 | * @param selectedValue
|
---|
34 | * the selected value
|
---|
35 | */
|
---|
36 | public ValueSelection(T selectedValue) {
|
---|
37 | this.selectedValue = selectedValue;
|
---|
38 | }
|
---|
39 |
|
---|
40 | /*
|
---|
41 | * (non-Javadoc)
|
---|
42 | *
|
---|
43 | * @see de.harms.attef.userinteraction.Interaction#getName()
|
---|
44 | */
|
---|
45 | public String getName() {
|
---|
46 | return "ValueSelection";
|
---|
47 | }
|
---|
48 |
|
---|
49 | /*
|
---|
50 | * (non-Javadoc)
|
---|
51 | *
|
---|
52 | * @see java.lang.Object#toString()
|
---|
53 | */
|
---|
54 | @Override
|
---|
55 | public String toString() {
|
---|
56 | return "select value";
|
---|
57 | }
|
---|
58 |
|
---|
59 | /*
|
---|
60 | * (non-Javadoc)
|
---|
61 | *
|
---|
62 | * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
|
---|
63 | */
|
---|
64 | public boolean startsLogicalSequence() {
|
---|
65 | return false;
|
---|
66 | }
|
---|
67 |
|
---|
68 | /*
|
---|
69 | * (non-Javadoc)
|
---|
70 | *
|
---|
71 | * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
|
---|
72 | */
|
---|
73 | public boolean finishesLogicalSequence() {
|
---|
74 | return false;
|
---|
75 | }
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * <p>
|
---|
79 | * Returns the selected value associated with this event.
|
---|
80 | * </p>
|
---|
81 | *
|
---|
82 | * @return the selectedValue
|
---|
83 | */
|
---|
84 | public T getSelectedValue() {
|
---|
85 | return selectedValue;
|
---|
86 | }
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * (non-Javadoc)
|
---|
90 | *
|
---|
91 | * @see java.lang.Object#equals(java.lang.Object)
|
---|
92 | */
|
---|
93 | @Override
|
---|
94 | public boolean equals(Object obj) {
|
---|
95 | if ((obj == null) || (!(obj instanceof ValueSelection<?>))) {
|
---|
96 | return false;
|
---|
97 | }
|
---|
98 |
|
---|
99 | ValueSelection<?> otherValueSelection = (ValueSelection<?>) obj;
|
---|
100 |
|
---|
101 | return ((otherValueSelection != null) && ((selectedValue == otherValueSelection.selectedValue) || ((selectedValue != null) && (selectedValue
|
---|
102 | .equals(otherValueSelection.selectedValue)))));
|
---|
103 | }
|
---|
104 |
|
---|
105 | /*
|
---|
106 | * (non-Javadoc)
|
---|
107 | *
|
---|
108 | * @see java.lang.Object#hashCode()
|
---|
109 | */
|
---|
110 | @Override
|
---|
111 | public int hashCode() {
|
---|
112 | return selectedValue.hashCode();
|
---|
113 | }
|
---|
114 |
|
---|
115 | }
|
---|