001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.config.impl;
008    
009    import java.io.File;
010    import java.util.Collection;
011    import java.util.logging.Logger;
012    
013    import org.codehaus.janino.ScriptEvaluator;
014    import org.eclipse.emf.common.notify.Notification;
015    import org.eclipse.emf.common.notify.NotificationChain;
016    import org.eclipse.emf.common.util.EList;
017    import org.eclipse.emf.ecore.EClass;
018    import org.eclipse.emf.ecore.InternalEObject;
019    import org.eclipse.emf.ecore.impl.ENotificationImpl;
020    import org.eclipse.emf.ecore.impl.EObjectImpl;
021    import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
022    import org.eclipse.emf.ecore.util.EObjectContainmentEList;
023    import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
024    import org.eclipse.emf.ecore.util.InternalEList;
025    
026    import com.hammurapi.config.ConfigPackage;
027    import com.hammurapi.config.Factory;
028    import com.hammurapi.config.Reference;
029    import com.hammurapi.config.Source;
030    import com.hammurapi.config.bootstrap.ConfigurationException;
031    import com.hammurapi.config.bootstrap.Destroyable;
032    import com.hammurapi.config.bootstrap.FactoryClosure;
033    import com.hammurapi.config.bootstrap.TokenExpander.TokenSource;
034    import com.hammurapi.config.runtime.FactoryConfig;
035    import com.hammurapi.party.PartyPackage;
036    import com.hammurapi.party.Role;
037    import com.hammurapi.config.runtime.FactoryClosureBase;
038    
039    /**
040     * <!-- begin-user-doc -->
041     * An implementation of the model object '<em><b>Reference</b></em>'.
042     * <!-- end-user-doc -->
043     * <p>
044     * The following features are implemented:
045     * <ul>
046     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#getRoles <em>Roles</em>}</li>
047     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#getDescription <em>Description</em>}</li>
048     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#getConfigScript <em>Config Script</em>}</li>
049     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#getId <em>Id</em>}</li>
050     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#getSource <em>Source</em>}</li>
051     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#isEnabled <em>Enabled</em>}</li>
052     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#getService <em>Service</em>}</li>
053     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#getSupportedExecutionEnvironments <em>Supported Execution Environments</em>}</li>
054     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#getHomePage <em>Home Page</em>}</li>
055     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#getRefId <em>Ref Id</em>}</li>
056     *   <li>{@link com.hammurapi.config.impl.ReferenceImpl#getRef <em>Ref</em>}</li>
057     * </ul>
058     * </p>
059     *
060     * @generated
061     */
062    public class ReferenceImpl extends EObjectImpl implements Reference {
063            /**
064             * The cached value of the '{@link #getRoles() <em>Roles</em>}' containment reference list.
065             * <!-- begin-user-doc -->
066             * <!-- end-user-doc -->
067             * @see #getRoles()
068             * @generated
069             * @ordered
070             */
071            protected EList<Role> roles;
072            private static final Logger logger = Logger.getLogger(ReferenceImpl.class.getName());
073            /**
074             * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
075             * <!-- begin-user-doc -->
076             * <!-- end-user-doc -->
077             * @see #getDescription()
078             * @generated
079             * @ordered
080             */
081            protected static final String DESCRIPTION_EDEFAULT = null;
082    
083            /**
084             * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
085             * <!-- begin-user-doc -->
086             * <!-- end-user-doc -->
087             * @see #getDescription()
088             * @generated
089             * @ordered
090             */
091            protected String description = DESCRIPTION_EDEFAULT;
092    
093            /**
094             * The default value of the '{@link #getConfigScript() <em>Config Script</em>}' attribute.
095             * <!-- begin-user-doc -->
096             * <!-- end-user-doc -->
097             * @see #getConfigScript()
098             * @generated
099             * @ordered
100             */
101            protected static final String CONFIG_SCRIPT_EDEFAULT = null;
102    
103            /**
104             * The cached value of the '{@link #getConfigScript() <em>Config Script</em>}' attribute.
105             * <!-- begin-user-doc -->
106             * <!-- end-user-doc -->
107             * @see #getConfigScript()
108             * @generated
109             * @ordered
110             */
111            protected String configScript = CONFIG_SCRIPT_EDEFAULT;
112    
113            /**
114             * The default value of the '{@link #getId() <em>Id</em>}' attribute.
115             * <!-- begin-user-doc -->
116             * <!-- end-user-doc -->
117             * @see #getId()
118             * @generated
119             * @ordered
120             */
121            protected static final String ID_EDEFAULT = null;
122    
123            /**
124             * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
125             * <!-- begin-user-doc -->
126             * <!-- end-user-doc -->
127             * @see #getId()
128             * @generated
129             * @ordered
130             */
131            protected String id = ID_EDEFAULT;
132    
133            /**
134             * The cached value of the '{@link #getSource() <em>Source</em>}' containment reference list.
135             * <!-- begin-user-doc -->
136             * <!-- end-user-doc -->
137             * @see #getSource()
138             * @generated
139             * @ordered
140             */
141            protected EList<Source> source;
142    
143            /**
144             * The default value of the '{@link #isEnabled() <em>Enabled</em>}' attribute.
145             * <!-- begin-user-doc -->
146             * <!-- end-user-doc -->
147             * @see #isEnabled()
148             * @generated
149             * @ordered
150             */
151            protected static final boolean ENABLED_EDEFAULT = true;
152    
153            /**
154             * The cached value of the '{@link #isEnabled() <em>Enabled</em>}' attribute.
155             * <!-- begin-user-doc -->
156             * <!-- end-user-doc -->
157             * @see #isEnabled()
158             * @generated
159             * @ordered
160             */
161            protected boolean enabled = ENABLED_EDEFAULT;
162    
163            /**
164             * The cached value of the '{@link #getService() <em>Service</em>}' attribute list.
165             * <!-- begin-user-doc -->
166             * <!-- end-user-doc -->
167             * @see #getService()
168             * @generated
169             * @ordered
170             */
171            protected EList<String> service;
172    
173            /**
174             * The cached value of the '{@link #getSupportedExecutionEnvironments() <em>Supported Execution Environments</em>}' attribute list.
175             * <!-- begin-user-doc -->
176             * <!-- end-user-doc -->
177             * @see #getSupportedExecutionEnvironments()
178             * @generated
179             * @ordered
180             */
181            protected EList<String> supportedExecutionEnvironments;
182            /**
183             * The default value of the '{@link #getHomePage() <em>Home Page</em>}' attribute.
184             * <!-- begin-user-doc -->
185             * <!-- end-user-doc -->
186             * @see #getHomePage()
187             * @generated
188             * @ordered
189             */
190            protected static final String HOME_PAGE_EDEFAULT = null;
191            /**
192             * The cached value of the '{@link #getHomePage() <em>Home Page</em>}' attribute.
193             * <!-- begin-user-doc -->
194             * <!-- end-user-doc -->
195             * @see #getHomePage()
196             * @generated
197             * @ordered
198             */
199            protected String homePage = HOME_PAGE_EDEFAULT;
200            /**
201             * The default value of the '{@link #getRefId() <em>Ref Id</em>}' attribute.
202             * <!-- begin-user-doc -->
203             * <!-- end-user-doc -->
204             * @see #getRefId()
205             * @generated
206             * @ordered
207             */
208            protected static final String REF_ID_EDEFAULT = null;
209    
210            /**
211             * The cached value of the '{@link #getRefId() <em>Ref Id</em>}' attribute.
212             * <!-- begin-user-doc -->
213             * <!-- end-user-doc -->
214             * @see #getRefId()
215             * @generated
216             * @ordered
217             */
218            protected String refId = REF_ID_EDEFAULT;
219    
220            /**
221             * The cached value of the '{@link #getRef() <em>Ref</em>}' reference.
222             * <!-- begin-user-doc -->
223             * <!-- end-user-doc -->
224             * @see #getRef()
225             * @generated
226             * @ordered
227             */
228            protected Factory ref;
229    
230            /**
231             * <!-- begin-user-doc -->
232             * <!-- end-user-doc -->
233             * @generated
234             */
235            protected ReferenceImpl() {
236                    super();
237            }
238    
239            /**
240             * <!-- begin-user-doc -->
241             * <!-- end-user-doc -->
242             * @generated
243             */
244            @Override
245            protected EClass eStaticClass() {
246                    return ConfigPackage.Literals.REFERENCE;
247            }
248    
249            /**
250             * <!-- begin-user-doc -->
251             * <!-- end-user-doc -->
252             * @generated
253             */
254            public EList<Role> getRoles() {
255                    if (roles == null) {
256                            roles = new EObjectContainmentWithInverseEList<Role>(Role.class, this, ConfigPackage.REFERENCE__ROLES, PartyPackage.ROLE__OWNER);
257                    }
258                    return roles;
259            }
260    
261            /**
262             * <!-- begin-user-doc -->
263             * <!-- end-user-doc -->
264             * @generated
265             */
266            public String getDescription() {
267                    return description;
268            }
269    
270            /**
271             * <!-- begin-user-doc -->
272             * <!-- end-user-doc -->
273             * @generated
274             */
275            public void setDescription(String newDescription) {
276                    String oldDescription = description;
277                    description = newDescription;
278                    if (eNotificationRequired())
279                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.REFERENCE__DESCRIPTION, oldDescription, description));
280            }
281    
282            /**
283             * <!-- begin-user-doc -->
284             * <!-- end-user-doc -->
285             * @generated
286             */
287            public String getConfigScript() {
288                    return configScript;
289            }
290    
291            /**
292             * <!-- begin-user-doc -->
293             * <!-- end-user-doc -->
294             * @generated
295             */
296            public void setConfigScript(String newConfigScript) {
297                    String oldConfigScript = configScript;
298                    configScript = newConfigScript;
299                    if (eNotificationRequired())
300                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.REFERENCE__CONFIG_SCRIPT, oldConfigScript, configScript));
301            }
302    
303            /**
304             * <!-- begin-user-doc -->
305             * <!-- end-user-doc -->
306             * @generated
307             */
308            public String getId() {
309                    return id;
310            }
311    
312            /**
313             * <!-- begin-user-doc -->
314             * <!-- end-user-doc -->
315             * @generated
316             */
317            public void setId(String newId) {
318                    String oldId = id;
319                    id = newId;
320                    if (eNotificationRequired())
321                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.REFERENCE__ID, oldId, id));
322            }
323    
324            /**
325             * <!-- begin-user-doc -->
326             * <!-- end-user-doc -->
327             * @generated
328             */
329            public EList<Source> getSource() {
330                    if (source == null) {
331                            source = new EObjectContainmentEList<Source>(Source.class, this, ConfigPackage.REFERENCE__SOURCE);
332                    }
333                    return source;
334            }
335    
336            /**
337             * <!-- begin-user-doc -->
338             * <!-- end-user-doc -->
339             * @generated
340             */
341            public boolean isEnabled() {
342                    return enabled;
343            }
344    
345            /**
346             * <!-- begin-user-doc -->
347             * <!-- end-user-doc -->
348             * @generated
349             */
350            public void setEnabled(boolean newEnabled) {
351                    boolean oldEnabled = enabled;
352                    enabled = newEnabled;
353                    if (eNotificationRequired())
354                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.REFERENCE__ENABLED, oldEnabled, enabled));
355            }
356    
357            /**
358             * <!-- begin-user-doc -->
359             * <!-- end-user-doc -->
360             * @generated
361             */
362            public EList<String> getService() {
363                    if (service == null) {
364                            service = new EDataTypeUniqueEList<String>(String.class, this, ConfigPackage.REFERENCE__SERVICE);
365                    }
366                    return service;
367            }
368    
369            /**
370             * <!-- begin-user-doc -->
371             * <!-- end-user-doc -->
372             * @generated
373             */
374            public EList<String> getSupportedExecutionEnvironments() {
375                    if (supportedExecutionEnvironments == null) {
376                            supportedExecutionEnvironments = new EDataTypeUniqueEList<String>(String.class, this, ConfigPackage.REFERENCE__SUPPORTED_EXECUTION_ENVIRONMENTS);
377                    }
378                    return supportedExecutionEnvironments;
379            }
380    
381            /**
382             * <!-- begin-user-doc -->
383             * <!-- end-user-doc -->
384             * @generated
385             */
386            public String getHomePage() {
387                    return homePage;
388            }
389    
390            /**
391             * <!-- begin-user-doc -->
392             * <!-- end-user-doc -->
393             * @generated
394             */
395            public void setHomePage(String newHomePage) {
396                    String oldHomePage = homePage;
397                    homePage = newHomePage;
398                    if (eNotificationRequired())
399                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.REFERENCE__HOME_PAGE, oldHomePage, homePage));
400            }
401    
402            /**
403             * <!-- begin-user-doc -->
404             * <!-- end-user-doc -->
405             * @generated
406             */
407            public String getRefId() {
408                    return refId;
409            }
410    
411            /**
412             * <!-- begin-user-doc -->
413             * <!-- end-user-doc -->
414             * @generated
415             */
416            public void setRefId(String newRefId) {
417                    String oldRefId = refId;
418                    refId = newRefId;
419                    if (eNotificationRequired())
420                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.REFERENCE__REF_ID, oldRefId, refId));
421            }
422    
423            /**
424             * <!-- begin-user-doc -->
425             * <!-- end-user-doc -->
426             * @generated
427             */
428            public Factory getRef() {
429                    if (ref != null && ref.eIsProxy()) {
430                            InternalEObject oldRef = (InternalEObject)ref;
431                            ref = (Factory)eResolveProxy(oldRef);
432                            if (ref != oldRef) {
433                                    if (eNotificationRequired())
434                                            eNotify(new ENotificationImpl(this, Notification.RESOLVE, ConfigPackage.REFERENCE__REF, oldRef, ref));
435                            }
436                    }
437                    return ref;
438            }
439    
440            /**
441             * <!-- begin-user-doc -->
442             * <!-- end-user-doc -->
443             * @generated
444             */
445            public Factory basicGetRef() {
446                    return ref;
447            }
448    
449            /**
450             * <!-- begin-user-doc -->
451             * <!-- end-user-doc -->
452             * @generated
453             */
454            public void setRef(Factory newRef) {
455                    Factory oldRef = ref;
456                    ref = newRef;
457                    if (eNotificationRequired())
458                            eNotify(new ENotificationImpl(this, Notification.SET, ConfigPackage.REFERENCE__REF, oldRef, ref));
459            }
460    
461            /**
462             * <!-- begin-user-doc -->
463             * <!-- end-user-doc -->
464             * @generated NOT
465             */
466            @SuppressWarnings("unchecked")
467            public FactoryClosure<Object> create(final FactoryConfig factoryConfig) throws ConfigurationException {
468                    if (getRefId()!=null && getRefId().trim().length()>0) {
469                            logger.fine("Creating a reference, refId="+getRefId());
470                            final Object ref = factoryConfig.getContext().lookup(getRefId());
471                            if (ref==null) {
472                                    throw new ConfigurationException("Unresolved reference: "+getRefId());
473                            }
474                            
475                            return new FactoryClosureBase<Object>() {
476                                    
477                                    {
478                                            if (ref instanceof FactoryClosure) {
479                                                    destroyableSink.addDestroyable(((FactoryClosure) ref).getDestroyable());
480                                            }                                       
481                                    }
482    
483                                    public Object create(Object... args) throws ConfigurationException {
484                                            if (ref instanceof FactoryClosure) {
485                                                    return ((FactoryClosure) ref).create(args);
486                                            }
487                                            if (args.length>0) {
488                                                    throw new ConfigurationException("create() with arguments is not supported");
489                                            }
490                                            return ref;
491                                    }
492                                    
493                            };
494                            
495                    }
496                    
497                    Factory refFactory = getRef();
498                    if (refFactory!=null) {
499                            logger.fine("Creating a reference");
500                            final FactoryClosure<Object> fr = refFactory.create(factoryConfig);
501                            return new FactoryClosure<Object>() {
502    
503                                    public Object create(Object... args) throws ConfigurationException {
504                                            Object ret = fr.create(args);
505                                            
506                                            // Execute script once reference is initialized
507                                            if (getConfigScript()!=null && getConfigScript().trim().length()>0) {
508                                                    ScriptEvaluator se = new ScriptEvaluator();
509                                                    se.setParameters(new String[] {"instance", "definition", "config"}, new Class[] {ret.getClass(), ReferenceImpl.class, factoryConfig.getClass()});
510                                                    se.setParentClassLoader(factoryConfig.getClassLoader());
511                                                    se.setThrownExceptions(new Class[] {ConfigurationException.class});
512                                                    try {
513                                                            se.cook(getConfigScript());
514                                                            se.evaluate(new Object[] {ret, ReferenceImpl.this, factoryConfig});
515                                                    } catch (Exception e) {
516                                                            throw new ConfigurationException(e);
517                                                    }
518                                            }
519                                            return ret;
520                                    }
521    
522                                    public Destroyable getDestroyable()     throws ConfigurationException {
523                                            return fr.getDestroyable();
524                                    }
525                                    
526                            };
527                            
528                    }
529                    throw new ConfigurationException("Either refId or ref shall be set");
530            }
531    
532            /**
533             * <!-- begin-user-doc -->
534             * <!-- end-user-doc -->
535             * @generated
536             */
537            public void compile(EList<String> profilePath, TokenSource tokens, ClassLoader classLoader, File dir, String targetPackage, String targetClass) throws ConfigurationException {
538                    // TODO: implement this method
539                    // Ensure that you remove @generated or mark it @generated NOT
540                    throw new UnsupportedOperationException();
541            }
542    
543            /**
544             * <!-- begin-user-doc -->
545             * <!-- end-user-doc -->
546             * @generated
547             */
548            @SuppressWarnings("unchecked")
549            @Override
550            public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
551                    switch (featureID) {
552                            case ConfigPackage.REFERENCE__ROLES:
553                                    return ((InternalEList<InternalEObject>)(InternalEList<?>)getRoles()).basicAdd(otherEnd, msgs);
554                    }
555                    return super.eInverseAdd(otherEnd, featureID, msgs);
556            }
557    
558            /**
559             * <!-- begin-user-doc -->
560             * <!-- end-user-doc -->
561             * @generated
562             */
563            @Override
564            public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
565                    switch (featureID) {
566                            case ConfigPackage.REFERENCE__ROLES:
567                                    return ((InternalEList<?>)getRoles()).basicRemove(otherEnd, msgs);
568                            case ConfigPackage.REFERENCE__SOURCE:
569                                    return ((InternalEList<?>)getSource()).basicRemove(otherEnd, msgs);
570                    }
571                    return super.eInverseRemove(otherEnd, featureID, msgs);
572            }
573    
574            /**
575             * <!-- begin-user-doc -->
576             * <!-- end-user-doc -->
577             * @generated
578             */
579            @Override
580            public Object eGet(int featureID, boolean resolve, boolean coreType) {
581                    switch (featureID) {
582                            case ConfigPackage.REFERENCE__ROLES:
583                                    return getRoles();
584                            case ConfigPackage.REFERENCE__DESCRIPTION:
585                                    return getDescription();
586                            case ConfigPackage.REFERENCE__CONFIG_SCRIPT:
587                                    return getConfigScript();
588                            case ConfigPackage.REFERENCE__ID:
589                                    return getId();
590                            case ConfigPackage.REFERENCE__SOURCE:
591                                    return getSource();
592                            case ConfigPackage.REFERENCE__ENABLED:
593                                    return isEnabled();
594                            case ConfigPackage.REFERENCE__SERVICE:
595                                    return getService();
596                            case ConfigPackage.REFERENCE__SUPPORTED_EXECUTION_ENVIRONMENTS:
597                                    return getSupportedExecutionEnvironments();
598                            case ConfigPackage.REFERENCE__HOME_PAGE:
599                                    return getHomePage();
600                            case ConfigPackage.REFERENCE__REF_ID:
601                                    return getRefId();
602                            case ConfigPackage.REFERENCE__REF:
603                                    if (resolve) return getRef();
604                                    return basicGetRef();
605                    }
606                    return super.eGet(featureID, resolve, coreType);
607            }
608    
609            /**
610             * <!-- begin-user-doc -->
611             * <!-- end-user-doc -->
612             * @generated
613             */
614            @SuppressWarnings("unchecked")
615            @Override
616            public void eSet(int featureID, Object newValue) {
617                    switch (featureID) {
618                            case ConfigPackage.REFERENCE__ROLES:
619                                    getRoles().clear();
620                                    getRoles().addAll((Collection<? extends Role>)newValue);
621                                    return;
622                            case ConfigPackage.REFERENCE__DESCRIPTION:
623                                    setDescription((String)newValue);
624                                    return;
625                            case ConfigPackage.REFERENCE__CONFIG_SCRIPT:
626                                    setConfigScript((String)newValue);
627                                    return;
628                            case ConfigPackage.REFERENCE__ID:
629                                    setId((String)newValue);
630                                    return;
631                            case ConfigPackage.REFERENCE__SOURCE:
632                                    getSource().clear();
633                                    getSource().addAll((Collection<? extends Source>)newValue);
634                                    return;
635                            case ConfigPackage.REFERENCE__ENABLED:
636                                    setEnabled((Boolean)newValue);
637                                    return;
638                            case ConfigPackage.REFERENCE__SERVICE:
639                                    getService().clear();
640                                    getService().addAll((Collection<? extends String>)newValue);
641                                    return;
642                            case ConfigPackage.REFERENCE__SUPPORTED_EXECUTION_ENVIRONMENTS:
643                                    getSupportedExecutionEnvironments().clear();
644                                    getSupportedExecutionEnvironments().addAll((Collection<? extends String>)newValue);
645                                    return;
646                            case ConfigPackage.REFERENCE__HOME_PAGE:
647                                    setHomePage((String)newValue);
648                                    return;
649                            case ConfigPackage.REFERENCE__REF_ID:
650                                    setRefId((String)newValue);
651                                    return;
652                            case ConfigPackage.REFERENCE__REF:
653                                    setRef((Factory)newValue);
654                                    return;
655                    }
656                    super.eSet(featureID, newValue);
657            }
658    
659            /**
660             * <!-- begin-user-doc -->
661             * <!-- end-user-doc -->
662             * @generated
663             */
664            @Override
665            public void eUnset(int featureID) {
666                    switch (featureID) {
667                            case ConfigPackage.REFERENCE__ROLES:
668                                    getRoles().clear();
669                                    return;
670                            case ConfigPackage.REFERENCE__DESCRIPTION:
671                                    setDescription(DESCRIPTION_EDEFAULT);
672                                    return;
673                            case ConfigPackage.REFERENCE__CONFIG_SCRIPT:
674                                    setConfigScript(CONFIG_SCRIPT_EDEFAULT);
675                                    return;
676                            case ConfigPackage.REFERENCE__ID:
677                                    setId(ID_EDEFAULT);
678                                    return;
679                            case ConfigPackage.REFERENCE__SOURCE:
680                                    getSource().clear();
681                                    return;
682                            case ConfigPackage.REFERENCE__ENABLED:
683                                    setEnabled(ENABLED_EDEFAULT);
684                                    return;
685                            case ConfigPackage.REFERENCE__SERVICE:
686                                    getService().clear();
687                                    return;
688                            case ConfigPackage.REFERENCE__SUPPORTED_EXECUTION_ENVIRONMENTS:
689                                    getSupportedExecutionEnvironments().clear();
690                                    return;
691                            case ConfigPackage.REFERENCE__HOME_PAGE:
692                                    setHomePage(HOME_PAGE_EDEFAULT);
693                                    return;
694                            case ConfigPackage.REFERENCE__REF_ID:
695                                    setRefId(REF_ID_EDEFAULT);
696                                    return;
697                            case ConfigPackage.REFERENCE__REF:
698                                    setRef((Factory)null);
699                                    return;
700                    }
701                    super.eUnset(featureID);
702            }
703    
704            /**
705             * <!-- begin-user-doc -->
706             * <!-- end-user-doc -->
707             * @generated
708             */
709            @Override
710            public boolean eIsSet(int featureID) {
711                    switch (featureID) {
712                            case ConfigPackage.REFERENCE__ROLES:
713                                    return roles != null && !roles.isEmpty();
714                            case ConfigPackage.REFERENCE__DESCRIPTION:
715                                    return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
716                            case ConfigPackage.REFERENCE__CONFIG_SCRIPT:
717                                    return CONFIG_SCRIPT_EDEFAULT == null ? configScript != null : !CONFIG_SCRIPT_EDEFAULT.equals(configScript);
718                            case ConfigPackage.REFERENCE__ID:
719                                    return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
720                            case ConfigPackage.REFERENCE__SOURCE:
721                                    return source != null && !source.isEmpty();
722                            case ConfigPackage.REFERENCE__ENABLED:
723                                    return enabled != ENABLED_EDEFAULT;
724                            case ConfigPackage.REFERENCE__SERVICE:
725                                    return service != null && !service.isEmpty();
726                            case ConfigPackage.REFERENCE__SUPPORTED_EXECUTION_ENVIRONMENTS:
727                                    return supportedExecutionEnvironments != null && !supportedExecutionEnvironments.isEmpty();
728                            case ConfigPackage.REFERENCE__HOME_PAGE:
729                                    return HOME_PAGE_EDEFAULT == null ? homePage != null : !HOME_PAGE_EDEFAULT.equals(homePage);
730                            case ConfigPackage.REFERENCE__REF_ID:
731                                    return REF_ID_EDEFAULT == null ? refId != null : !REF_ID_EDEFAULT.equals(refId);
732                            case ConfigPackage.REFERENCE__REF:
733                                    return ref != null;
734                    }
735                    return super.eIsSet(featureID);
736            }
737    
738            /**
739             * <!-- begin-user-doc -->
740             * <!-- end-user-doc -->
741             * @generated
742             */
743            @Override
744            public String toString() {
745                    if (eIsProxy()) return super.toString();
746    
747                    StringBuffer result = new StringBuffer(super.toString());
748                    result.append(" (description: ");
749                    result.append(description);
750                    result.append(", configScript: ");
751                    result.append(configScript);
752                    result.append(", id: ");
753                    result.append(id);
754                    result.append(", enabled: ");
755                    result.append(enabled);
756                    result.append(", service: ");
757                    result.append(service);
758                    result.append(", supportedExecutionEnvironments: ");
759                    result.append(supportedExecutionEnvironments);
760                    result.append(", homePage: ");
761                    result.append(homePage);
762                    result.append(", refId: ");
763                    result.append(refId);
764                    result.append(')');
765                    return result.toString();
766            }
767    
768    } //ReferenceImpl