    001    /**
    002     * <copyright>
    003     * </copyright>
    004     *
    005     * $Id$
    006     */
    007    package com.hammurapi.eventbus.snapshot.impl;
    008
    009    import com.hammurapi.eventbus.snapshot.Derivation;
    010    import com.hammurapi.eventbus.snapshot.Event;
    011    import com.hammurapi.eventbus.snapshot.Handler;
    012    import com.hammurapi.eventbus.snapshot.SnapshotPackage;
    013
    014    import java.util.Collection;
    015
    016    import org.eclipse.emf.common.notify.Notification;
    017
    018    import org.eclipse.emf.common.notify.NotificationChain;
    019    import org.eclipse.emf.common.util.EList;
    020
    021    import org.eclipse.emf.ecore.EClass;
    022    import org.eclipse.emf.ecore.InternalEObject;
    023
    024    import org.eclipse.emf.ecore.impl.ENotificationImpl;
    025    import org.eclipse.emf.ecore.impl.EObjectImpl;
    026
    027    import org.eclipse.emf.ecore.util.EObjectContainmentEList;
    028    import org.eclipse.emf.ecore.util.InternalEList;
    029    import org.eclipse.emf.ecore.util.EObjectResolvingEList;
    030
    031    /**
    032     * <!-- begin-user-doc -->
    033     * An implementation of the model object '<em><b>Derivation</b></em>'.
    034     * <!-- end-user-doc -->
    035     * <p>
    036     * The following features are implemented:
    037     * <ul>
    038     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.DerivationImpl#getHandler <em>Handler</em>}</li>
    039     *   <li>{@link com.hammurapi.eventbus.snapshot.impl.DerivationImpl#getInputs <em>Inputs</em>}</li>
    040     * </ul>
    041     * </p>
    042     *
    043     * @generated
    044     */
    045    public class DerivationImpl extends EObjectImpl implements Derivation {
    046            /**
    047             * The cached value of the '{@link #getHandler() <em>Handler</em>}' reference.
    048             * <!-- begin-user-doc -->
    049             * <!-- end-user-doc -->
    050             * @see #getHandler()
    051             * @generated
    052             * @ordered
    053             */
    054            protected Handler handler;
    055
    056            /**
    057             * The cached value of the '{@link #getInputs() <em>Inputs</em>}' reference list.
    058             * <!-- begin-user-doc -->
    059             * <!-- end-user-doc -->
    060             * @see #getInputs()
    061             * @generated
    062             * @ordered
    063             */
    064            protected EList<Event> inputs;
    065
    066            /**
    067             * <!-- begin-user-doc -->
    068             * <!-- end-user-doc -->
    069             * @generated
    070             */
    071            protected DerivationImpl() {
    072                    super();
    073            }
    074
    075            /**
    076             * <!-- begin-user-doc -->
    077             * <!-- end-user-doc -->
    078             * @generated
    079             */
    080            @Override
    081            protected EClass eStaticClass() {
    082                    return SnapshotPackage.Literals.DERIVATION;
    083            }
    084
    085            /**
    086             * <!-- begin-user-doc -->
    087             * <!-- end-user-doc -->
    088             * @generated
    089             */
    090            public Handler getHandler() {
    091                    if (handler != null && handler.eIsProxy()) {
    092                            InternalEObject oldHandler = (InternalEObject)handler;
    093                            handler = (Handler)eResolveProxy(oldHandler);
    094                            if (handler != oldHandler) {
    095                                    if (eNotificationRequired())
    096                                            eNotify(new ENotificationImpl(this, Notification.RESOLVE, SnapshotPackage.DERIVATION__HANDLER, oldHandler, handler));
    097                            }
    098                    }
    099                    return handler;
    100            }
    101
    102            /**
    103             * <!-- begin-user-doc -->
    104             * <!-- end-user-doc -->
    105             * @generated
    106             */
    107            public Handler basicGetHandler() {
    108                    return handler;
    109            }
    110
    111            /**
    112             * <!-- begin-user-doc -->
    113             * <!-- end-user-doc -->
    114             * @generated
    115             */
    116            public void setHandler(Handler newHandler) {
    117                    Handler oldHandler = handler;
    118                    handler = newHandler;
    119                    if (eNotificationRequired())
    120                            eNotify(new ENotificationImpl(this, Notification.SET, SnapshotPackage.DERIVATION__HANDLER, oldHandler, handler));
    121            }
    122
    123            /**
    124             * <!-- begin-user-doc -->
    125             * <!-- end-user-doc -->
    126             * @generated
    127             */
    128            public EList<Event> getInputs() {
    129                    if (inputs == null) {
    130                            inputs = new EObjectResolvingEList<Event>(Event.class, this, SnapshotPackage.DERIVATION__INPUTS);
    131                    }
    132                    return inputs;
    133            }
    134
    135            /**
    136             * <!-- begin-user-doc -->
    137             * <!-- end-user-doc -->
    138             * @generated
    139             */
    140            @Override
    141            public Object eGet(int featureID, boolean resolve, boolean coreType) {
    142                    switch (featureID) {
    143                            case SnapshotPackage.DERIVATION__HANDLER:
    144                                    if (resolve) return getHandler();
    145                                    return basicGetHandler();
    146                            case SnapshotPackage.DERIVATION__INPUTS:
    147                                    return getInputs();
    148                    }
    149                    return super.eGet(featureID, resolve, coreType);
    150            }
    151
    152            /**
    153             * <!-- begin-user-doc -->
    154             * <!-- end-user-doc -->
    155             * @generated
    156             */
    157            @SuppressWarnings("unchecked")
    158            @Override
    159            public void eSet(int featureID, Object newValue) {
    160                    switch (featureID) {
    161                            case SnapshotPackage.DERIVATION__HANDLER:
    162                                    setHandler((Handler)newValue);
    163                                    return;
    164                            case SnapshotPackage.DERIVATION__INPUTS:
    165                                    getInputs().clear();
    166                                    getInputs().addAll((Collection<? extends Event>)newValue);
    167                                    return;
    168                    }
    169                    super.eSet(featureID, newValue);
    170            }
    171
    172            /**
    173             * <!-- begin-user-doc -->
    174             * <!-- end-user-doc -->
    175             * @generated
    176             */
    177            @Override
    178            public void eUnset(int featureID) {
    179                    switch (featureID) {
    180                            case SnapshotPackage.DERIVATION__HANDLER:
    181                                    setHandler((Handler)null);
    182                                    return;
    183                            case SnapshotPackage.DERIVATION__INPUTS:
    184                                    getInputs().clear();
    185                                    return;
    186                    }
    187                    super.eUnset(featureID);
    188            }
    189
    190            /**
    191             * <!-- begin-user-doc -->
    192             * <!-- end-user-doc -->
    193             * @generated
    194             */
    195            @Override
    196            public boolean eIsSet(int featureID) {
    197                    switch (featureID) {
    198                            case SnapshotPackage.DERIVATION__HANDLER:
    199                                    return handler != null;
    200                            case SnapshotPackage.DERIVATION__INPUTS:
    201                                    return inputs != null && !inputs.isEmpty();
    202                    }
    203                    return super.eIsSet(featureID);
    204            }
    205
    206    } //DerivationImpl