001/**
002 * ******************************************************************************
003 * Copyright (c) 2018 Red Hat Inc
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *  *
009 * Contributors:
010 *     Jens Reimann - initial API and implementation
011 *  ******************************************************************************
012 */
013package de.dentrassi.varlink.idl.varlinkIdl.impl;
014
015import de.dentrassi.varlink.idl.varlinkIdl.ElementType;
016import de.dentrassi.varlink.idl.varlinkIdl.Optional;
017import de.dentrassi.varlink.idl.varlinkIdl.VarlinkIdlPackage;
018
019import org.eclipse.emf.common.notify.Notification;
020import org.eclipse.emf.common.notify.NotificationChain;
021
022import org.eclipse.emf.ecore.EClass;
023import org.eclipse.emf.ecore.InternalEObject;
024
025import org.eclipse.emf.ecore.impl.ENotificationImpl;
026
027/**
028 * <!-- begin-user-doc -->
029 * An implementation of the model object '<em><b>Optional</b></em>'.
030 * <!-- end-user-doc -->
031 * <p>
032 * The following features are implemented:
033 * </p>
034 * <ul>
035 *   <li>{@link de.dentrassi.varlink.idl.varlinkIdl.impl.OptionalImpl#getType <em>Type</em>}</li>
036 * </ul>
037 *
038 * @generated
039 */
040public class OptionalImpl extends ElementTypeImpl implements Optional
041{
042  /**
043   * The cached value of the '{@link #getType() <em>Type</em>}' containment reference.
044   * <!-- begin-user-doc -->
045   * <!-- end-user-doc -->
046   * @see #getType()
047   * @generated
048   * @ordered
049   */
050  protected ElementType type;
051
052  /**
053   * <!-- begin-user-doc -->
054   * <!-- end-user-doc -->
055   * @generated
056   */
057  protected OptionalImpl()
058  {
059    super();
060  }
061
062  /**
063   * <!-- begin-user-doc -->
064   * <!-- end-user-doc -->
065   * @generated
066   */
067  @Override
068  protected EClass eStaticClass()
069  {
070    return VarlinkIdlPackage.Literals.OPTIONAL;
071  }
072
073  /**
074   * <!-- begin-user-doc -->
075   * <!-- end-user-doc -->
076   * @generated
077   */
078  public ElementType getType()
079  {
080    return type;
081  }
082
083  /**
084   * <!-- begin-user-doc -->
085   * <!-- end-user-doc -->
086   * @generated
087   */
088  public NotificationChain basicSetType(ElementType newType, NotificationChain msgs)
089  {
090    ElementType oldType = type;
091    type = newType;
092    if (eNotificationRequired())
093    {
094      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, VarlinkIdlPackage.OPTIONAL__TYPE, oldType, newType);
095      if (msgs == null) msgs = notification; else msgs.add(notification);
096    }
097    return msgs;
098  }
099
100  /**
101   * <!-- begin-user-doc -->
102   * <!-- end-user-doc -->
103   * @generated
104   */
105  public void setType(ElementType newType)
106  {
107    if (newType != type)
108    {
109      NotificationChain msgs = null;
110      if (type != null)
111        msgs = ((InternalEObject)type).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - VarlinkIdlPackage.OPTIONAL__TYPE, null, msgs);
112      if (newType != null)
113        msgs = ((InternalEObject)newType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - VarlinkIdlPackage.OPTIONAL__TYPE, null, msgs);
114      msgs = basicSetType(newType, msgs);
115      if (msgs != null) msgs.dispatch();
116    }
117    else if (eNotificationRequired())
118      eNotify(new ENotificationImpl(this, Notification.SET, VarlinkIdlPackage.OPTIONAL__TYPE, newType, newType));
119  }
120
121  /**
122   * <!-- begin-user-doc -->
123   * <!-- end-user-doc -->
124   * @generated
125   */
126  @Override
127  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
128  {
129    switch (featureID)
130    {
131      case VarlinkIdlPackage.OPTIONAL__TYPE:
132        return basicSetType(null, msgs);
133    }
134    return super.eInverseRemove(otherEnd, featureID, msgs);
135  }
136
137  /**
138   * <!-- begin-user-doc -->
139   * <!-- end-user-doc -->
140   * @generated
141   */
142  @Override
143  public Object eGet(int featureID, boolean resolve, boolean coreType)
144  {
145    switch (featureID)
146    {
147      case VarlinkIdlPackage.OPTIONAL__TYPE:
148        return getType();
149    }
150    return super.eGet(featureID, resolve, coreType);
151  }
152
153  /**
154   * <!-- begin-user-doc -->
155   * <!-- end-user-doc -->
156   * @generated
157   */
158  @Override
159  public void eSet(int featureID, Object newValue)
160  {
161    switch (featureID)
162    {
163      case VarlinkIdlPackage.OPTIONAL__TYPE:
164        setType((ElementType)newValue);
165        return;
166    }
167    super.eSet(featureID, newValue);
168  }
169
170  /**
171   * <!-- begin-user-doc -->
172   * <!-- end-user-doc -->
173   * @generated
174   */
175  @Override
176  public void eUnset(int featureID)
177  {
178    switch (featureID)
179    {
180      case VarlinkIdlPackage.OPTIONAL__TYPE:
181        setType((ElementType)null);
182        return;
183    }
184    super.eUnset(featureID);
185  }
186
187  /**
188   * <!-- begin-user-doc -->
189   * <!-- end-user-doc -->
190   * @generated
191   */
192  @Override
193  public boolean eIsSet(int featureID)
194  {
195    switch (featureID)
196    {
197      case VarlinkIdlPackage.OPTIONAL__TYPE:
198        return type != null;
199    }
200    return super.eIsSet(featureID);
201  }
202
203} //OptionalImpl