1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.featureconfig.impl; |
8 | |
9 | import java.util.Collection; |
10 | |
11 | import org.eclipse.emf.common.notify.Notification; |
12 | import org.eclipse.emf.common.notify.NotificationChain; |
13 | import org.eclipse.emf.common.util.EList; |
14 | import org.eclipse.emf.ecore.EClass; |
15 | import org.eclipse.emf.ecore.InternalEObject; |
16 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
17 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
18 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
19 | import org.eclipse.emf.ecore.util.InternalEList; |
20 | |
21 | import de.uka.ipd.sdq.featureconfig.Configuration; |
22 | import de.uka.ipd.sdq.featureconfig.FeatureConfig; |
23 | import de.uka.ipd.sdq.featureconfig.featureconfigPackage; |
24 | |
25 | /** |
26 | * <!-- begin-user-doc --> |
27 | * An implementation of the model object '<em><b>Configuration</b></em>'. |
28 | * <!-- end-user-doc --> |
29 | * <p> |
30 | * The following features are implemented: |
31 | * <ul> |
32 | * <li>{@link de.uka.ipd.sdq.featureconfig.impl.ConfigurationImpl#getDefaultConfig <em>Default Config</em>}</li> |
33 | * <li>{@link de.uka.ipd.sdq.featureconfig.impl.ConfigurationImpl#getName <em>Name</em>}</li> |
34 | * <li>{@link de.uka.ipd.sdq.featureconfig.impl.ConfigurationImpl#getConfigOverrides <em>Config Overrides</em>}</li> |
35 | * </ul> |
36 | * </p> |
37 | * |
38 | * @generated |
39 | */ |
40 | public class ConfigurationImpl extends EObjectImpl implements Configuration { |
41 | /** |
42 | * The cached value of the '{@link #getDefaultConfig() <em>Default Config</em>}' containment reference. |
43 | * <!-- begin-user-doc --> |
44 | * <!-- end-user-doc --> |
45 | * @see #getDefaultConfig() |
46 | * @generated |
47 | * @ordered |
48 | */ |
49 | protected FeatureConfig defaultConfig; |
50 | |
51 | /** |
52 | * The default value of the '{@link #getName() <em>Name</em>}' attribute. |
53 | * <!-- begin-user-doc --> |
54 | * <!-- end-user-doc --> |
55 | * @see #getName() |
56 | * @generated |
57 | * @ordered |
58 | */ |
59 | protected static final String NAME_EDEFAULT = null; |
60 | |
61 | /** |
62 | * The cached value of the '{@link #getName() <em>Name</em>}' attribute. |
63 | * <!-- begin-user-doc --> |
64 | * <!-- end-user-doc --> |
65 | * @see #getName() |
66 | * @generated |
67 | * @ordered |
68 | */ |
69 | protected String name = NAME_EDEFAULT; |
70 | |
71 | /** |
72 | * The cached value of the '{@link #getConfigOverrides() <em>Config Overrides</em>}' containment reference list. |
73 | * <!-- begin-user-doc --> |
74 | * <!-- end-user-doc --> |
75 | * @see #getConfigOverrides() |
76 | * @generated |
77 | * @ordered |
78 | */ |
79 | protected EList<FeatureConfig> configOverrides; |
80 | |
81 | /** |
82 | * <!-- begin-user-doc --> |
83 | * <!-- end-user-doc --> |
84 | * @generated |
85 | */ |
86 | protected ConfigurationImpl() { |
87 | super(); |
88 | } |
89 | |
90 | /** |
91 | * <!-- begin-user-doc --> |
92 | * <!-- end-user-doc --> |
93 | * @generated |
94 | */ |
95 | @Override |
96 | protected EClass eStaticClass() { |
97 | return featureconfigPackage.Literals.CONFIGURATION; |
98 | } |
99 | |
100 | /** |
101 | * <!-- begin-user-doc --> |
102 | * <!-- end-user-doc --> |
103 | * @generated |
104 | */ |
105 | public EList<FeatureConfig> getConfigOverrides() { |
106 | if (configOverrides == null) { |
107 | configOverrides = new EObjectContainmentWithInverseEList<FeatureConfig>(FeatureConfig.class, this, featureconfigPackage.CONFIGURATION__CONFIG_OVERRIDES, featureconfigPackage.FEATURE_CONFIG__CONFIGURATION_OVERRIDES); |
108 | } |
109 | return configOverrides; |
110 | } |
111 | |
112 | /** |
113 | * <!-- begin-user-doc --> |
114 | * <!-- end-user-doc --> |
115 | * @generated |
116 | */ |
117 | @SuppressWarnings("unchecked") |
118 | @Override |
119 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
120 | switch (featureID) { |
121 | case featureconfigPackage.CONFIGURATION__DEFAULT_CONFIG: |
122 | if (defaultConfig != null) |
123 | msgs = ((InternalEObject)defaultConfig).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - featureconfigPackage.CONFIGURATION__DEFAULT_CONFIG, null, msgs); |
124 | return basicSetDefaultConfig((FeatureConfig)otherEnd, msgs); |
125 | case featureconfigPackage.CONFIGURATION__CONFIG_OVERRIDES: |
126 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getConfigOverrides()).basicAdd(otherEnd, msgs); |
127 | } |
128 | return super.eInverseAdd(otherEnd, featureID, msgs); |
129 | } |
130 | |
131 | /** |
132 | * <!-- begin-user-doc --> |
133 | * <!-- end-user-doc --> |
134 | * @generated |
135 | */ |
136 | public FeatureConfig getDefaultConfig() { |
137 | return defaultConfig; |
138 | } |
139 | |
140 | /** |
141 | * <!-- begin-user-doc --> |
142 | * <!-- end-user-doc --> |
143 | * @generated |
144 | */ |
145 | public NotificationChain basicSetDefaultConfig(FeatureConfig newDefaultConfig, NotificationChain msgs) { |
146 | FeatureConfig oldDefaultConfig = defaultConfig; |
147 | defaultConfig = newDefaultConfig; |
148 | if (eNotificationRequired()) { |
149 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, featureconfigPackage.CONFIGURATION__DEFAULT_CONFIG, oldDefaultConfig, newDefaultConfig); |
150 | if (msgs == null) msgs = notification; else msgs.add(notification); |
151 | } |
152 | return msgs; |
153 | } |
154 | |
155 | /** |
156 | * <!-- begin-user-doc --> |
157 | * <!-- end-user-doc --> |
158 | * @generated |
159 | */ |
160 | public void setDefaultConfig(FeatureConfig newDefaultConfig) { |
161 | if (newDefaultConfig != defaultConfig) { |
162 | NotificationChain msgs = null; |
163 | if (defaultConfig != null) |
164 | msgs = ((InternalEObject)defaultConfig).eInverseRemove(this, featureconfigPackage.FEATURE_CONFIG__CONFIGURATION_DEFAULT, FeatureConfig.class, msgs); |
165 | if (newDefaultConfig != null) |
166 | msgs = ((InternalEObject)newDefaultConfig).eInverseAdd(this, featureconfigPackage.FEATURE_CONFIG__CONFIGURATION_DEFAULT, FeatureConfig.class, msgs); |
167 | msgs = basicSetDefaultConfig(newDefaultConfig, msgs); |
168 | if (msgs != null) msgs.dispatch(); |
169 | } |
170 | else if (eNotificationRequired()) |
171 | eNotify(new ENotificationImpl(this, Notification.SET, featureconfigPackage.CONFIGURATION__DEFAULT_CONFIG, newDefaultConfig, newDefaultConfig)); |
172 | } |
173 | |
174 | /** |
175 | * <!-- begin-user-doc --> |
176 | * <!-- end-user-doc --> |
177 | * @generated |
178 | */ |
179 | public String getName() { |
180 | return name; |
181 | } |
182 | |
183 | /** |
184 | * <!-- begin-user-doc --> |
185 | * <!-- end-user-doc --> |
186 | * @generated |
187 | */ |
188 | public void setName(String newName) { |
189 | String oldName = name; |
190 | name = newName; |
191 | if (eNotificationRequired()) |
192 | eNotify(new ENotificationImpl(this, Notification.SET, featureconfigPackage.CONFIGURATION__NAME, oldName, name)); |
193 | } |
194 | |
195 | /** |
196 | * <!-- begin-user-doc --> |
197 | * <!-- end-user-doc --> |
198 | * @generated |
199 | */ |
200 | @Override |
201 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
202 | switch (featureID) { |
203 | case featureconfigPackage.CONFIGURATION__DEFAULT_CONFIG: |
204 | return basicSetDefaultConfig(null, msgs); |
205 | case featureconfigPackage.CONFIGURATION__CONFIG_OVERRIDES: |
206 | return ((InternalEList<?>)getConfigOverrides()).basicRemove(otherEnd, msgs); |
207 | } |
208 | return super.eInverseRemove(otherEnd, featureID, msgs); |
209 | } |
210 | |
211 | /** |
212 | * <!-- begin-user-doc --> |
213 | * <!-- end-user-doc --> |
214 | * @generated |
215 | */ |
216 | @Override |
217 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
218 | switch (featureID) { |
219 | case featureconfigPackage.CONFIGURATION__DEFAULT_CONFIG: |
220 | return getDefaultConfig(); |
221 | case featureconfigPackage.CONFIGURATION__NAME: |
222 | return getName(); |
223 | case featureconfigPackage.CONFIGURATION__CONFIG_OVERRIDES: |
224 | return getConfigOverrides(); |
225 | } |
226 | return super.eGet(featureID, resolve, coreType); |
227 | } |
228 | |
229 | /** |
230 | * <!-- begin-user-doc --> |
231 | * <!-- end-user-doc --> |
232 | * @generated |
233 | */ |
234 | @SuppressWarnings("unchecked") |
235 | @Override |
236 | public void eSet(int featureID, Object newValue) { |
237 | switch (featureID) { |
238 | case featureconfigPackage.CONFIGURATION__DEFAULT_CONFIG: |
239 | setDefaultConfig((FeatureConfig)newValue); |
240 | return; |
241 | case featureconfigPackage.CONFIGURATION__NAME: |
242 | setName((String)newValue); |
243 | return; |
244 | case featureconfigPackage.CONFIGURATION__CONFIG_OVERRIDES: |
245 | getConfigOverrides().clear(); |
246 | getConfigOverrides().addAll((Collection<? extends FeatureConfig>)newValue); |
247 | return; |
248 | } |
249 | super.eSet(featureID, newValue); |
250 | } |
251 | |
252 | /** |
253 | * <!-- begin-user-doc --> |
254 | * <!-- end-user-doc --> |
255 | * @generated |
256 | */ |
257 | @Override |
258 | public void eUnset(int featureID) { |
259 | switch (featureID) { |
260 | case featureconfigPackage.CONFIGURATION__DEFAULT_CONFIG: |
261 | setDefaultConfig((FeatureConfig)null); |
262 | return; |
263 | case featureconfigPackage.CONFIGURATION__NAME: |
264 | setName(NAME_EDEFAULT); |
265 | return; |
266 | case featureconfigPackage.CONFIGURATION__CONFIG_OVERRIDES: |
267 | getConfigOverrides().clear(); |
268 | return; |
269 | } |
270 | super.eUnset(featureID); |
271 | } |
272 | |
273 | /** |
274 | * <!-- begin-user-doc --> |
275 | * <!-- end-user-doc --> |
276 | * @generated |
277 | */ |
278 | @Override |
279 | public boolean eIsSet(int featureID) { |
280 | switch (featureID) { |
281 | case featureconfigPackage.CONFIGURATION__DEFAULT_CONFIG: |
282 | return defaultConfig != null; |
283 | case featureconfigPackage.CONFIGURATION__NAME: |
284 | return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
285 | case featureconfigPackage.CONFIGURATION__CONFIG_OVERRIDES: |
286 | return configOverrides != null && !configOverrides.isEmpty(); |
287 | } |
288 | return super.eIsSet(featureID); |
289 | } |
290 | |
291 | /** |
292 | * <!-- begin-user-doc --> |
293 | * <!-- end-user-doc --> |
294 | * @generated |
295 | */ |
296 | @Override |
297 | public String toString() { |
298 | if (eIsProxy()) return super.toString(); |
299 | |
300 | StringBuffer result = new StringBuffer(super.toString()); |
301 | result.append(" (name: "); |
302 | result.append(name); |
303 | result.append(')'); |
304 | return result.toString(); |
305 | } |
306 | |
307 | } //ConfigurationImpl |