1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.featuremodel.impl; |
8 | |
9 | import java.util.Collection; |
10 | |
11 | import org.eclipse.emf.common.notify.Notification; |
12 | import org.eclipse.emf.common.util.EList; |
13 | import org.eclipse.emf.ecore.EClass; |
14 | import org.eclipse.emf.ecore.InternalEObject; |
15 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
16 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
17 | |
18 | import de.uka.ipd.sdq.featuremodel.Constraint; |
19 | import de.uka.ipd.sdq.featuremodel.Feature; |
20 | import de.uka.ipd.sdq.featuremodel.featuremodelPackage; |
21 | |
22 | /** |
23 | * <!-- begin-user-doc --> |
24 | * An implementation of the model object '<em><b>Constraint</b></em>'. |
25 | * <!-- end-user-doc --> |
26 | * <p> |
27 | * The following features are implemented: |
28 | * <ul> |
29 | * <li>{@link de.uka.ipd.sdq.featuremodel.impl.ConstraintImpl#getSource <em>Source</em>}</li> |
30 | * <li>{@link de.uka.ipd.sdq.featuremodel.impl.ConstraintImpl#getTarget <em>Target</em>}</li> |
31 | * <li>{@link de.uka.ipd.sdq.featuremodel.impl.ConstraintImpl#getDescription <em>Description</em>}</li> |
32 | * </ul> |
33 | * </p> |
34 | * |
35 | * @generated |
36 | */ |
37 | public abstract class ConstraintImpl extends NamedElementImpl implements Constraint { |
38 | /** |
39 | * The cached value of the '{@link #getSource() <em>Source</em>}' reference. |
40 | * <!-- begin-user-doc --> |
41 | * <!-- end-user-doc --> |
42 | * @see #getSource() |
43 | * @generated |
44 | * @ordered |
45 | */ |
46 | protected Feature source; |
47 | |
48 | /** |
49 | * The cached value of the '{@link #getTarget() <em>Target</em>}' reference list. |
50 | * <!-- begin-user-doc --> |
51 | * <!-- end-user-doc --> |
52 | * @see #getTarget() |
53 | * @generated |
54 | * @ordered |
55 | */ |
56 | protected EList<Feature> target; |
57 | |
58 | /** |
59 | * The default value of the '{@link #getDescription() <em>Description</em>}' attribute. |
60 | * <!-- begin-user-doc --> |
61 | * <!-- end-user-doc --> |
62 | * @see #getDescription() |
63 | * @generated |
64 | * @ordered |
65 | */ |
66 | protected static final String DESCRIPTION_EDEFAULT = null; |
67 | |
68 | /** |
69 | * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute. |
70 | * <!-- begin-user-doc --> |
71 | * <!-- end-user-doc --> |
72 | * @see #getDescription() |
73 | * @generated |
74 | * @ordered |
75 | */ |
76 | protected String description = DESCRIPTION_EDEFAULT; |
77 | |
78 | /** |
79 | * <!-- begin-user-doc --> |
80 | * <!-- end-user-doc --> |
81 | * @generated |
82 | */ |
83 | protected ConstraintImpl() { |
84 | super(); |
85 | } |
86 | |
87 | /** |
88 | * <!-- begin-user-doc --> |
89 | * <!-- end-user-doc --> |
90 | * @generated |
91 | */ |
92 | @Override |
93 | protected EClass eStaticClass() { |
94 | return featuremodelPackage.Literals.CONSTRAINT; |
95 | } |
96 | |
97 | /** |
98 | * <!-- begin-user-doc --> |
99 | * <!-- end-user-doc --> |
100 | * @generated |
101 | */ |
102 | public Feature getSource() { |
103 | if (source != null && source.eIsProxy()) { |
104 | InternalEObject oldSource = (InternalEObject)source; |
105 | source = (Feature)eResolveProxy(oldSource); |
106 | if (source != oldSource) { |
107 | if (eNotificationRequired()) |
108 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, featuremodelPackage.CONSTRAINT__SOURCE, oldSource, source)); |
109 | } |
110 | } |
111 | return source; |
112 | } |
113 | |
114 | /** |
115 | * <!-- begin-user-doc --> |
116 | * <!-- end-user-doc --> |
117 | * @generated |
118 | */ |
119 | public Feature basicGetSource() { |
120 | return source; |
121 | } |
122 | |
123 | /** |
124 | * <!-- begin-user-doc --> |
125 | * <!-- end-user-doc --> |
126 | * @generated |
127 | */ |
128 | public void setSource(Feature newSource) { |
129 | Feature oldSource = source; |
130 | source = newSource; |
131 | if (eNotificationRequired()) |
132 | eNotify(new ENotificationImpl(this, Notification.SET, featuremodelPackage.CONSTRAINT__SOURCE, oldSource, source)); |
133 | } |
134 | |
135 | /** |
136 | * <!-- begin-user-doc --> |
137 | * <!-- end-user-doc --> |
138 | * @generated |
139 | */ |
140 | public EList<Feature> getTarget() { |
141 | if (target == null) { |
142 | target = new EObjectResolvingEList<Feature>(Feature.class, this, featuremodelPackage.CONSTRAINT__TARGET); |
143 | } |
144 | return target; |
145 | } |
146 | |
147 | /** |
148 | * <!-- begin-user-doc --> |
149 | * <!-- end-user-doc --> |
150 | * @generated |
151 | */ |
152 | public String getDescription() { |
153 | return description; |
154 | } |
155 | |
156 | /** |
157 | * <!-- begin-user-doc --> |
158 | * <!-- end-user-doc --> |
159 | * @generated |
160 | */ |
161 | public void setDescription(String newDescription) { |
162 | String oldDescription = description; |
163 | description = newDescription; |
164 | if (eNotificationRequired()) |
165 | eNotify(new ENotificationImpl(this, Notification.SET, featuremodelPackage.CONSTRAINT__DESCRIPTION, oldDescription, description)); |
166 | } |
167 | |
168 | /** |
169 | * <!-- begin-user-doc --> |
170 | * <!-- end-user-doc --> |
171 | * @generated |
172 | */ |
173 | @Override |
174 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
175 | switch (featureID) { |
176 | case featuremodelPackage.CONSTRAINT__SOURCE: |
177 | if (resolve) return getSource(); |
178 | return basicGetSource(); |
179 | case featuremodelPackage.CONSTRAINT__TARGET: |
180 | return getTarget(); |
181 | case featuremodelPackage.CONSTRAINT__DESCRIPTION: |
182 | return getDescription(); |
183 | } |
184 | return super.eGet(featureID, resolve, coreType); |
185 | } |
186 | |
187 | /** |
188 | * <!-- begin-user-doc --> |
189 | * <!-- end-user-doc --> |
190 | * @generated |
191 | */ |
192 | @SuppressWarnings("unchecked") |
193 | @Override |
194 | public void eSet(int featureID, Object newValue) { |
195 | switch (featureID) { |
196 | case featuremodelPackage.CONSTRAINT__SOURCE: |
197 | setSource((Feature)newValue); |
198 | return; |
199 | case featuremodelPackage.CONSTRAINT__TARGET: |
200 | getTarget().clear(); |
201 | getTarget().addAll((Collection<? extends Feature>)newValue); |
202 | return; |
203 | case featuremodelPackage.CONSTRAINT__DESCRIPTION: |
204 | setDescription((String)newValue); |
205 | return; |
206 | } |
207 | super.eSet(featureID, newValue); |
208 | } |
209 | |
210 | /** |
211 | * <!-- begin-user-doc --> |
212 | * <!-- end-user-doc --> |
213 | * @generated |
214 | */ |
215 | @Override |
216 | public void eUnset(int featureID) { |
217 | switch (featureID) { |
218 | case featuremodelPackage.CONSTRAINT__SOURCE: |
219 | setSource((Feature)null); |
220 | return; |
221 | case featuremodelPackage.CONSTRAINT__TARGET: |
222 | getTarget().clear(); |
223 | return; |
224 | case featuremodelPackage.CONSTRAINT__DESCRIPTION: |
225 | setDescription(DESCRIPTION_EDEFAULT); |
226 | return; |
227 | } |
228 | super.eUnset(featureID); |
229 | } |
230 | |
231 | /** |
232 | * <!-- begin-user-doc --> |
233 | * <!-- end-user-doc --> |
234 | * @generated |
235 | */ |
236 | @Override |
237 | public boolean eIsSet(int featureID) { |
238 | switch (featureID) { |
239 | case featuremodelPackage.CONSTRAINT__SOURCE: |
240 | return source != null; |
241 | case featuremodelPackage.CONSTRAINT__TARGET: |
242 | return target != null && !target.isEmpty(); |
243 | case featuremodelPackage.CONSTRAINT__DESCRIPTION: |
244 | return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description); |
245 | } |
246 | return super.eIsSet(featureID); |
247 | } |
248 | |
249 | /** |
250 | * <!-- begin-user-doc --> |
251 | * <!-- end-user-doc --> |
252 | * @generated |
253 | */ |
254 | @Override |
255 | public String toString() { |
256 | if (eIsProxy()) return super.toString(); |
257 | |
258 | StringBuffer result = new StringBuffer(super.toString()); |
259 | result.append(" (description: "); |
260 | result.append(description); |
261 | result.append(')'); |
262 | return result.toString(); |
263 | } |
264 | |
265 | } //ConstraintImpl |