/** * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * * http://www.apache.org/licenses/LICENSE-2.0 * * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.thingml.xtext.thingML.impl; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; import org.thingml.xtext.thingML.Expression; import org.thingml.xtext.thingML.ThingMLPackage; import org.thingml.xtext.thingML.Type; import org.thingml.xtext.thingML.TypeRef; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Type Ref</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.thingml.xtext.thingML.impl.TypeRefImpl#getType <em>Type</em>}</li> * <li>{@link org.thingml.xtext.thingML.impl.TypeRefImpl#isIsArray <em>Is Array</em>}</li> * <li>{@link org.thingml.xtext.thingML.impl.TypeRefImpl#getCardinality <em>Cardinality</em>}</li> * </ul> * * @generated */ public class TypeRefImpl extends MinimalEObjectImpl.Container implements TypeRef { /** * The cached value of the '{@link #getType() <em>Type</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getType() * @generated * @ordered */ protected Type type; /** * The default value of the '{@link #isIsArray() <em>Is Array</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isIsArray() * @generated * @ordered */ protected static final boolean IS_ARRAY_EDEFAULT = false; /** * The cached value of the '{@link #isIsArray() <em>Is Array</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isIsArray() * @generated * @ordered */ protected boolean isArray = IS_ARRAY_EDEFAULT; /** * The cached value of the '{@link #getCardinality() <em>Cardinality</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getCardinality() * @generated * @ordered */ protected Expression cardinality; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected TypeRefImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return ThingMLPackage.Literals.TYPE_REF; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Type getType() { if (type != null && type.eIsProxy()) { InternalEObject oldType = (InternalEObject)type; type = (Type)eResolveProxy(oldType); if (type != oldType) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, ThingMLPackage.TYPE_REF__TYPE, oldType, type)); } } return type; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Type basicGetType() { return type; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setType(Type newType) { Type oldType = type; type = newType; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ThingMLPackage.TYPE_REF__TYPE, oldType, type)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean isIsArray() { return isArray; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setIsArray(boolean newIsArray) { boolean oldIsArray = isArray; isArray = newIsArray; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ThingMLPackage.TYPE_REF__IS_ARRAY, oldIsArray, isArray)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Expression getCardinality() { return cardinality; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetCardinality(Expression newCardinality, NotificationChain msgs) { Expression oldCardinality = cardinality; cardinality = newCardinality; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThingMLPackage.TYPE_REF__CARDINALITY, oldCardinality, newCardinality); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setCardinality(Expression newCardinality) { if (newCardinality != cardinality) { NotificationChain msgs = null; if (cardinality != null) msgs = ((InternalEObject)cardinality).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.TYPE_REF__CARDINALITY, null, msgs); if (newCardinality != null) msgs = ((InternalEObject)newCardinality).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.TYPE_REF__CARDINALITY, null, msgs); msgs = basicSetCardinality(newCardinality, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ThingMLPackage.TYPE_REF__CARDINALITY, newCardinality, newCardinality)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ThingMLPackage.TYPE_REF__CARDINALITY: return basicSetCardinality(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case ThingMLPackage.TYPE_REF__TYPE: if (resolve) return getType(); return basicGetType(); case ThingMLPackage.TYPE_REF__IS_ARRAY: return isIsArray(); case ThingMLPackage.TYPE_REF__CARDINALITY: return getCardinality(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case ThingMLPackage.TYPE_REF__TYPE: setType((Type)newValue); return; case ThingMLPackage.TYPE_REF__IS_ARRAY: setIsArray((Boolean)newValue); return; case ThingMLPackage.TYPE_REF__CARDINALITY: setCardinality((Expression)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ThingMLPackage.TYPE_REF__TYPE: setType((Type)null); return; case ThingMLPackage.TYPE_REF__IS_ARRAY: setIsArray(IS_ARRAY_EDEFAULT); return; case ThingMLPackage.TYPE_REF__CARDINALITY: setCardinality((Expression)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ThingMLPackage.TYPE_REF__TYPE: return type != null; case ThingMLPackage.TYPE_REF__IS_ARRAY: return isArray != IS_ARRAY_EDEFAULT; case ThingMLPackage.TYPE_REF__CARDINALITY: return cardinality != null; } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (isArray: "); result.append(isArray); result.append(')'); return result.toString(); } } //TypeRefImpl