/**
* 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.sintef.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.EObjectImpl;
import org.sintef.thingml.Expression;
import org.sintef.thingml.ThingmlPackage;
import org.sintef.thingml.Type;
import org.sintef.thingml.TypedElement;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Typed Element</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.sintef.thingml.impl.TypedElementImpl#getType <em>Type</em>}</li>
* <li>{@link org.sintef.thingml.impl.TypedElementImpl#getCardinality <em>Cardinality</em>}</li>
* <li>{@link org.sintef.thingml.impl.TypedElementImpl#isIsArray <em>Is Array</em>}</li>
* </ul>
*
* @generated
*/
public abstract class TypedElementImpl extends EObjectImpl implements TypedElement {
/**
* 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 cached value of the '{@link #getCardinality() <em>Cardinality</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCardinality()
* @generated
* @ordered
*/
protected Expression cardinality;
/**
* 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 = true;
/**
* 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;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TypedElementImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ThingmlPackage.Literals.TYPED_ELEMENT;
}
/**
* <!-- 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.TYPED_ELEMENT__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.TYPED_ELEMENT__TYPE, oldType, type));
}
/**
* <!-- 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.TYPED_ELEMENT__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.TYPED_ELEMENT__CARDINALITY, null, msgs);
if (newCardinality != null)
msgs = ((InternalEObject)newCardinality).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThingmlPackage.TYPED_ELEMENT__CARDINALITY, null, msgs);
msgs = basicSetCardinality(newCardinality, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ThingmlPackage.TYPED_ELEMENT__CARDINALITY, newCardinality, newCardinality));
}
/**
* <!-- 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.TYPED_ELEMENT__IS_ARRAY, oldIsArray, isArray));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ThingmlPackage.TYPED_ELEMENT__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.TYPED_ELEMENT__TYPE:
if (resolve) return getType();
return basicGetType();
case ThingmlPackage.TYPED_ELEMENT__CARDINALITY:
return getCardinality();
case ThingmlPackage.TYPED_ELEMENT__IS_ARRAY:
return isIsArray();
}
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.TYPED_ELEMENT__TYPE:
setType((Type)newValue);
return;
case ThingmlPackage.TYPED_ELEMENT__CARDINALITY:
setCardinality((Expression)newValue);
return;
case ThingmlPackage.TYPED_ELEMENT__IS_ARRAY:
setIsArray((Boolean)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ThingmlPackage.TYPED_ELEMENT__TYPE:
setType((Type)null);
return;
case ThingmlPackage.TYPED_ELEMENT__CARDINALITY:
setCardinality((Expression)null);
return;
case ThingmlPackage.TYPED_ELEMENT__IS_ARRAY:
setIsArray(IS_ARRAY_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ThingmlPackage.TYPED_ELEMENT__TYPE:
return type != null;
case ThingmlPackage.TYPED_ELEMENT__CARDINALITY:
return cardinality != null;
case ThingmlPackage.TYPED_ELEMENT__IS_ARRAY:
return isArray != IS_ARRAY_EDEFAULT;
}
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();
}
} //TypedElementImpl