001 /**
002 * <copyright>
003 * </copyright>
004 *
005 * $Id$
006 */
007 package com.hammurapi.config.impl;
008
009 import com.hammurapi.config.ConfigPackage;
010 import com.hammurapi.config.Null;
011 import com.hammurapi.config.Source;
012
013 import com.hammurapi.config.bootstrap.ConfigurationException;
014 import com.hammurapi.config.bootstrap.Destroyable;
015 import com.hammurapi.config.bootstrap.FactoryClosure;
016 import com.hammurapi.config.bootstrap.TokenExpander.TokenSource;
017 import com.hammurapi.config.runtime.FactoryConfig;
018
019
020 import com.hammurapi.party.PartyPackage;
021 import com.hammurapi.party.Role;
022 import java.io.File;
023
024 import java.util.Collection;
025
026 import org.eclipse.emf.common.notify.Notification;
027 import org.eclipse.emf.common.notify.NotificationChain;
028
029 import org.eclipse.emf.common.util.EList;
030
031 import org.eclipse.emf.ecore.EClass;
032 import org.eclipse.emf.ecore.InternalEObject;
033
034 import org.eclipse.emf.ecore.impl.ENotificationImpl;
035 import org.eclipse.emf.ecore.impl.EObjectImpl;
036
037 import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
038 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
039 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
040 import org.eclipse.emf.ecore.util.InternalEList;
041
042 /**
043 * <!-- begin-user-doc -->
044 * An implementation of the model object '<em><b>Null</b></em>'.
045 * <!-- end-user-doc -->
046 * <p>
047 * The following features are implemented:
048 * <ul>
049 * <li>{@link com.hammurapi.config.impl.NullImpl#getRoles <em>Roles</em>}</li>
050 * <li>{@link com.hammurapi.config.impl.NullImpl#getDescription <em>Description</em>}</li>
051 * <li>{@link com.hammurapi.config.impl.NullImpl#getConfigScript <em>Config Script</em>}</li>
052 * <li>{@link com.hammurapi.config.impl.NullImpl#getId <em>Id</em>}</li>
053 * <li>{@link com.hammurapi.config.impl.NullImpl#getSource <em>Source</em>}</li>
054 * <li>{@link com.hammurapi.config.impl.NullImpl#isEnabled <em>Enabled</em>}</li>
055 * <li>{@link com.hammurapi.config.impl.NullImpl#getService <em>Service</em>}</li>
056 * <li>{@link com.hammurapi.config.impl.NullImpl#getSupportedExecutionEnvironments <em>Supported Execution Environments</em>}</li>
057 * <li>{@link com.hammurapi.config.impl.NullImpl#getHomePage <em>Home Page</em>}</li>
058 * </ul>
059 * </p>
060 *
061 * @generated
062 */
063 public class NullImpl extends EObjectImpl implements Null {
064 /**
065 * The cached value of the '{@link #getRoles() <em>Roles</em>}' containment reference list.
066 * <!-- begin-user-doc -->
067 * <!-- end-user-doc -->
068 * @see #getRoles()
069 * @generated
070 * @ordered
071 */
072 protected EList<Role> roles;
073
074 /**
075 * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
076 * <!-- begin-user-doc -->
077 * <!-- end-user-doc -->
078 * @see #getDescription()
079 * @generated
080 * @ordered
081 */
082 protected static final String DESCRIPTION_EDEFAULT = null;
083
084 /**
085 * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
086 * <!-- begin-user-doc -->
087 * <!-- end-user-doc -->
088 * @see #getDescription()
089 * @generated
090 * @ordered
091 */
092 protected String description = DESCRIPTION_EDEFAULT;
093
094 /**
095 * The default value of the '{@link #getConfigScript() <em>Config Script</em>}' attribute.
096 * <!-- begin-user-doc -->
097 * <!-- end-user-doc -->
098 * @see #getConfigScript()
099 * @generated
100 * @ordered
101 */
102 protected static final String CONFIG_SCRIPT_EDEFAULT = null;
103
104 /**
105 * The cached value of the '{@link #getConfigScript() <em>Config Script</em>}' attribute.
106 * <!-- begin-user-doc -->
107 * <!-- end-user-doc -->
108 * @see #getConfigScript()
109 * @generated
110 * @ordered
111 */
112 protected String configScript = CONFIG_SCRIPT_EDEFAULT;
113
114 /**
115 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
116 * <!-- begin-user-doc -->
117 * <!-- end-user-doc -->
118 * @see #getId()
119 * @generated
120 * @ordered
121 */
122 protected static final String ID_EDEFAULT = null;
123
124 /**
125 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
126 * <!-- begin-user-doc -->
127 * <!-- end-user-doc -->
128 * @see #getId()
129 * @generated
130 * @ordered
131 */
132 protected String id = ID_EDEFAULT;
133
134 /**
135 * The cached value of the '{@link #getSource() <em>Source</em>}' containment reference list.
136 * <!-- begin-user-doc -->
137 * <!-- end-user-doc -->
138 * @see #getSource()
139 * @generated
140 * @ordered
141 */
142 protected EList<Source> source;
143
144 /**
145 * The default value of the '{@link #isEnabled() <em>Enabled</em>}' attribute.
146 * <!-- begin-user-doc -->
147 * <!-- end-user-doc -->
148 * @see #isEnabled()
149 * @generated
150 * @ordered
151 */
152 protected static final boolean ENABLED_EDEFAULT = true;
153
154 /**
155 * The cached value of the '{@link #isEnabled() <em>Enabled</em>}' attribute.
156 * <!-- begin-user-doc -->
157 * <!-- end-user-doc -->
158 * @see #isEnabled()
159 * @generated
160 * @ordered
161 */
162 protected boolean enabled = ENABLED_EDEFAULT;
163
164 /**
165 * The cached value of the '{@link #getService() <em>Service</em>}' attribute list.
166 * <!-- begin-user-doc -->
167 * <!-- end-user-doc -->
168 * @see #getService()
169 * @generated
170 * @ordered
171 */
172 protected EList<String> service;
173
174 /**
175 * The cached value of the '{@link #getSupportedExecutionEnvironments() <em>Supported Execution Environments</em>}' attribute list.
176 * <!-- begin-user-doc -->
177 * <!-- end-user-doc -->
178 * @see #getSupportedExecutionEnvironments()
179 * @generated
180 * @ordered
181 */
182 protected EList<String> supportedExecutionEnvironments;
183
184 /**
185 * The default value of the '{@link #getHomePage() <em>Home Page</em>}' attribute.
186 * <!-- begin-user-doc -->
187 * <!-- end-user-doc -->
188 * @see #getHomePage()
189 * @generated
190 * @ordered
191 */
192 protected static final String HOME_PAGE_EDEFAULT = null;
193
194 /**
195 * The cached value of the '{@link #getHomePage() <em>Home Page</em>}' attribute.
196 * <!-- begin-user-doc -->
197 * <!-- end-user-doc -->
198 * @see #getHomePage()
199 * @generated
200 * @ordered
201 */
202 protected String homePage = HOME_PAGE_EDEFAULT;
203
204 /**
205 * <!-- begin-user-doc -->
206 * <!-- end-user-doc -->
207 * @generated
208 */
209 protected NullImpl() {
210 super();
211 }
212
213 /**
214 * <!-- begin-user-doc -->
215 * <!-- end-user-doc -->
216 * @generated
217 */
218 @Override
219 protected EClass eStaticClass() {
220 return ConfigPackage.Literals.NULL;
221 }
222
223 /**
224 * <!-- begin-user-doc -->
225 * <!-- end-user-doc -->
226 * @generated
227 */
228 public EList<Role> getRoles() {
229 if (roles == null) {
230 roles = new EObjectContainmentWithInverseEList<Role>(Role.class, this, ConfigPackage.NULL__ROLES, PartyPackage.ROLE__OWNER);
231 }
232 return roles;
233 }
234
235 /**
236 * <!-- begin-user-doc -->
237 * <!-- end-user-doc -->
238 * @generated
239 */
240 public String getDescription() {
241 return description;
242 }
243
244 /**
245 * <!-- begin-user-doc -->
246 * <!-- end-user-doc -->
247 * @generated
248 */
249 public void setDescription(String newDescription) {
250 String oldDescription = description;
251 description = newDescription;
252 if (eNotificationRequired())
253 eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NULL__DESCRIPTION, oldDescription, description));
254 }
255
256 /**
257 * <!-- begin-user-doc -->
258 * <!-- end-user-doc -->
259 * @generated
260 */
261 public String getConfigScript() {
262 return configScript;
263 }
264
265 /**
266 * <!-- begin-user-doc -->
267 * <!-- end-user-doc -->
268 * @generated
269 */
270 public void setConfigScript(String newConfigScript) {
271 String oldConfigScript = configScript;
272 configScript = newConfigScript;
273 if (eNotificationRequired())
274 eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NULL__CONFIG_SCRIPT, oldConfigScript, configScript));
275 }
276
277 /**
278 * <!-- begin-user-doc -->
279 * <!-- end-user-doc -->
280 * @generated
281 */
282 public String getId() {
283 return id;
284 }
285
286 /**
287 * <!-- begin-user-doc -->
288 * <!-- end-user-doc -->
289 * @generated
290 */
291 public void setId(String newId) {
292 String oldId = id;
293 id = newId;
294 if (eNotificationRequired())
295 eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NULL__ID, oldId, id));
296 }
297
298 /**
299 * <!-- begin-user-doc -->
300 * <!-- end-user-doc -->
301 * @generated
302 */
303 public EList<Source> getSource() {
304 if (source == null) {
305 source = new EObjectContainmentEList<Source>(Source.class, this, ConfigPackage.NULL__SOURCE);
306 }
307 return source;
308 }
309
310 /**
311 * <!-- begin-user-doc -->
312 * <!-- end-user-doc -->
313 * @generated
314 */
315 public boolean isEnabled() {
316 return enabled;
317 }
318
319 /**
320 * <!-- begin-user-doc -->
321 * <!-- end-user-doc -->
322 * @generated
323 */
324 public void setEnabled(boolean newEnabled) {
325 boolean oldEnabled = enabled;
326 enabled = newEnabled;
327 if (eNotificationRequired())
328 eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NULL__ENABLED, oldEnabled, enabled));
329 }
330
331 /**
332 * <!-- begin-user-doc -->
333 * <!-- end-user-doc -->
334 * @generated
335 */
336 public EList<String> getService() {
337 if (service == null) {
338 service = new EDataTypeUniqueEList<String>(String.class, this, ConfigPackage.NULL__SERVICE);
339 }
340 return service;
341 }
342
343 /**
344 * <!-- begin-user-doc -->
345 * <!-- end-user-doc -->
346 * @generated
347 */
348 public EList<String> getSupportedExecutionEnvironments() {
349 if (supportedExecutionEnvironments == null) {
350 supportedExecutionEnvironments = new EDataTypeUniqueEList<String>(String.class, this, ConfigPackage.NULL__SUPPORTED_EXECUTION_ENVIRONMENTS);
351 }
352 return supportedExecutionEnvironments;
353 }
354
355 /**
356 * <!-- begin-user-doc -->
357 * <!-- end-user-doc -->
358 * @generated
359 */
360 public String getHomePage() {
361 return homePage;
362 }
363
364 /**
365 * <!-- begin-user-doc -->
366 * <!-- end-user-doc -->
367 * @generated
368 */
369 public void setHomePage(String newHomePage) {
370 String oldHomePage = homePage;
371 homePage = newHomePage;
372 if (eNotificationRequired())
373 eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.NULL__HOME_PAGE, oldHomePage, homePage));
374 }
375
376 /**
377 * <!-- begin-user-doc -->
378 * <!-- end-user-doc -->
379 * @generated NOT
380 */
381 public FactoryClosure<Object> create(FactoryConfig factoryConfig) throws ConfigurationException {
382 // Always returns null.
383 return new FactoryClosure<Object>() {
384
385 public Object create(Object... args) throws ConfigurationException {
386 if (args.length>0) {
387 throw new ConfigurationException("create() with arguments is not supported for Null");
388 }
389 return null;
390 }
391
392 public Destroyable getDestroyable() throws ConfigurationException {
393 return null;
394 }
395 };
396 }
397
398 /**
399 * <!-- begin-user-doc -->
400 * <!-- end-user-doc -->
401 * @generated
402 */
403 public void compile(EList<String> profilePath, TokenSource tokens, ClassLoader classLoader, File dir, String targetPackage, String targetClass) throws ConfigurationException {
404 // TODO: implement this method
405 // Ensure that you remove @generated or mark it @generated NOT
406 throw new UnsupportedOperationException();
407 }
408
409 /**
410 * <!-- begin-user-doc -->
411 * <!-- end-user-doc -->
412 * @generated
413 */
414 @SuppressWarnings("unchecked")
415 @Override
416 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
417 switch (featureID) {
418 case ConfigPackage.NULL__ROLES:
419 return ((InternalEList<InternalEObject>)(InternalEList<?>)getRoles()).basicAdd(otherEnd, msgs);
420 }
421 return super.eInverseAdd(otherEnd, featureID, msgs);
422 }
423
424 /**
425 * <!-- begin-user-doc -->
426 * <!-- end-user-doc -->
427 * @generated
428 */
429 @Override
430 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
431 switch (featureID) {
432 case ConfigPackage.NULL__ROLES:
433 return ((InternalEList<?>)getRoles()).basicRemove(otherEnd, msgs);
434 case ConfigPackage.NULL__SOURCE:
435 return ((InternalEList<?>)getSource()).basicRemove(otherEnd, msgs);
436 }
437 return super.eInverseRemove(otherEnd, featureID, msgs);
438 }
439
440 /**
441 * <!-- begin-user-doc -->
442 * <!-- end-user-doc -->
443 * @generated
444 */
445 @Override
446 public Object eGet(int featureID, boolean resolve, boolean coreType) {
447 switch (featureID) {
448 case ConfigPackage.NULL__ROLES:
449 return getRoles();
450 case ConfigPackage.NULL__DESCRIPTION:
451 return getDescription();
452 case ConfigPackage.NULL__CONFIG_SCRIPT:
453 return getConfigScript();
454 case ConfigPackage.NULL__ID:
455 return getId();
456 case ConfigPackage.NULL__SOURCE:
457 return getSource();
458 case ConfigPackage.NULL__ENABLED:
459 return isEnabled();
460 case ConfigPackage.NULL__SERVICE:
461 return getService();
462 case ConfigPackage.NULL__SUPPORTED_EXECUTION_ENVIRONMENTS:
463 return getSupportedExecutionEnvironments();
464 case ConfigPackage.NULL__HOME_PAGE:
465 return getHomePage();
466 }
467 return super.eGet(featureID, resolve, coreType);
468 }
469
470 /**
471 * <!-- begin-user-doc -->
472 * <!-- end-user-doc -->
473 * @generated
474 */
475 @SuppressWarnings("unchecked")
476 @Override
477 public void eSet(int featureID, Object newValue) {
478 switch (featureID) {
479 case ConfigPackage.NULL__ROLES:
480 getRoles().clear();
481 getRoles().addAll((Collection<? extends Role>)newValue);
482 return;
483 case ConfigPackage.NULL__DESCRIPTION:
484 setDescription((String)newValue);
485 return;
486 case ConfigPackage.NULL__CONFIG_SCRIPT:
487 setConfigScript((String)newValue);
488 return;
489 case ConfigPackage.NULL__ID:
490 setId((String)newValue);
491 return;
492 case ConfigPackage.NULL__SOURCE:
493 getSource().clear();
494 getSource().addAll((Collection<? extends Source>)newValue);
495 return;
496 case ConfigPackage.NULL__ENABLED:
497 setEnabled((Boolean)newValue);
498 return;
499 case ConfigPackage.NULL__SERVICE:
500 getService().clear();
501 getService().addAll((Collection<? extends String>)newValue);
502 return;
503 case ConfigPackage.NULL__SUPPORTED_EXECUTION_ENVIRONMENTS:
504 getSupportedExecutionEnvironments().clear();
505 getSupportedExecutionEnvironments().addAll((Collection<? extends String>)newValue);
506 return;
507 case ConfigPackage.NULL__HOME_PAGE:
508 setHomePage((String)newValue);
509 return;
510 }
511 super.eSet(featureID, newValue);
512 }
513
514 /**
515 * <!-- begin-user-doc -->
516 * <!-- end-user-doc -->
517 * @generated
518 */
519 @Override
520 public void eUnset(int featureID) {
521 switch (featureID) {
522 case ConfigPackage.NULL__ROLES:
523 getRoles().clear();
524 return;
525 case ConfigPackage.NULL__DESCRIPTION:
526 setDescription(DESCRIPTION_EDEFAULT);
527 return;
528 case ConfigPackage.NULL__CONFIG_SCRIPT:
529 setConfigScript(CONFIG_SCRIPT_EDEFAULT);
530 return;
531 case ConfigPackage.NULL__ID:
532 setId(ID_EDEFAULT);
533 return;
534 case ConfigPackage.NULL__SOURCE:
535 getSource().clear();
536 return;
537 case ConfigPackage.NULL__ENABLED:
538 setEnabled(ENABLED_EDEFAULT);
539 return;
540 case ConfigPackage.NULL__SERVICE:
541 getService().clear();
542 return;
543 case ConfigPackage.NULL__SUPPORTED_EXECUTION_ENVIRONMENTS:
544 getSupportedExecutionEnvironments().clear();
545 return;
546 case ConfigPackage.NULL__HOME_PAGE:
547 setHomePage(HOME_PAGE_EDEFAULT);
548 return;
549 }
550 super.eUnset(featureID);
551 }
552
553 /**
554 * <!-- begin-user-doc -->
555 * <!-- end-user-doc -->
556 * @generated
557 */
558 @Override
559 public boolean eIsSet(int featureID) {
560 switch (featureID) {
561 case ConfigPackage.NULL__ROLES:
562 return roles != null && !roles.isEmpty();
563 case ConfigPackage.NULL__DESCRIPTION:
564 return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
565 case ConfigPackage.NULL__CONFIG_SCRIPT:
566 return CONFIG_SCRIPT_EDEFAULT == null ? configScript != null : !CONFIG_SCRIPT_EDEFAULT.equals(configScript);
567 case ConfigPackage.NULL__ID:
568 return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
569 case ConfigPackage.NULL__SOURCE:
570 return source != null && !source.isEmpty();
571 case ConfigPackage.NULL__ENABLED:
572 return enabled != ENABLED_EDEFAULT;
573 case ConfigPackage.NULL__SERVICE:
574 return service != null && !service.isEmpty();
575 case ConfigPackage.NULL__SUPPORTED_EXECUTION_ENVIRONMENTS:
576 return supportedExecutionEnvironments != null && !supportedExecutionEnvironments.isEmpty();
577 case ConfigPackage.NULL__HOME_PAGE:
578 return HOME_PAGE_EDEFAULT == null ? homePage != null : !HOME_PAGE_EDEFAULT.equals(homePage);
579 }
580 return super.eIsSet(featureID);
581 }
582
583 /**
584 * <!-- begin-user-doc -->
585 * <!-- end-user-doc -->
586 * @generated
587 */
588 @Override
589 public String toString() {
590 if (eIsProxy()) return super.toString();
591
592 StringBuffer result = new StringBuffer(super.toString());
593 result.append(" (description: ");
594 result.append(description);
595 result.append(", configScript: ");
596 result.append(configScript);
597 result.append(", id: ");
598 result.append(id);
599 result.append(", enabled: ");
600 result.append(enabled);
601 result.append(", service: ");
602 result.append(service);
603 result.append(", supportedExecutionEnvironments: ");
604 result.append(supportedExecutionEnvironments);
605 result.append(", homePage: ");
606 result.append(homePage);
607 result.append(')');
608 return result.toString();
609 }
610
611 } //NullImpl