blob: 7d10b48fb5d6b9eb74ba88e6ff09484bbfe2bc3a [file] [log] [blame]
/**
*
* Copyright (c) 2009 Hatha Systems.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Nikolai Mansourov (Hatha Systems) - initial API and implementation
* Gabriel Barbier (Mia-Software) - minor evolutions for version 1.1
*
* $Id$
*/
package org.eclipse.gmt.modisco.omg.kdm.code.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.gmt.modisco.omg.kdm.code.ArrayType;
import org.eclipse.gmt.modisco.omg.kdm.code.CodePackage;
import org.eclipse.gmt.modisco.omg.kdm.code.IndexUnit;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Array Type</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.gmt.modisco.omg.kdm.code.impl.ArrayTypeImpl#getSize <em>Size</em>}</li>
* <li>{@link org.eclipse.gmt.modisco.omg.kdm.code.impl.ArrayTypeImpl#getIndexUnit <em>Index Unit</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ArrayTypeImpl extends DerivedTypeImpl implements ArrayType {
/**
* The default value of the '{@link #getSize() <em>Size</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSize()
* @generated
* @ordered
*/
protected static final Integer SIZE_EDEFAULT = null;
/**
* The cached value of the '{@link #getSize() <em>Size</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSize()
* @generated
* @ordered
*/
protected Integer size = SIZE_EDEFAULT;
/**
* The cached value of the '{@link #getIndexUnit() <em>Index Unit</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIndexUnit()
* @generated
* @ordered
*/
protected IndexUnit indexUnit;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ArrayTypeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CodePackage.Literals.ARRAY_TYPE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Integer getSize() {
return size;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSize(Integer newSize) {
Integer oldSize = size;
size = newSize;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CodePackage.ARRAY_TYPE__SIZE, oldSize, size));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public IndexUnit getIndexUnit() {
return indexUnit;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetIndexUnit(IndexUnit newIndexUnit, NotificationChain msgs) {
IndexUnit oldIndexUnit = indexUnit;
indexUnit = newIndexUnit;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CodePackage.ARRAY_TYPE__INDEX_UNIT, oldIndexUnit, newIndexUnit);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setIndexUnit(IndexUnit newIndexUnit) {
if (newIndexUnit != indexUnit) {
NotificationChain msgs = null;
if (indexUnit != null)
msgs = ((InternalEObject)indexUnit).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CodePackage.ARRAY_TYPE__INDEX_UNIT, null, msgs);
if (newIndexUnit != null)
msgs = ((InternalEObject)newIndexUnit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CodePackage.ARRAY_TYPE__INDEX_UNIT, null, msgs);
msgs = basicSetIndexUnit(newIndexUnit, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CodePackage.ARRAY_TYPE__INDEX_UNIT, newIndexUnit, newIndexUnit));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CodePackage.ARRAY_TYPE__INDEX_UNIT:
return basicSetIndexUnit(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 CodePackage.ARRAY_TYPE__SIZE:
return getSize();
case CodePackage.ARRAY_TYPE__INDEX_UNIT:
return getIndexUnit();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case CodePackage.ARRAY_TYPE__SIZE:
setSize((Integer)newValue);
return;
case CodePackage.ARRAY_TYPE__INDEX_UNIT:
setIndexUnit((IndexUnit)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CodePackage.ARRAY_TYPE__SIZE:
setSize(SIZE_EDEFAULT);
return;
case CodePackage.ARRAY_TYPE__INDEX_UNIT:
setIndexUnit((IndexUnit)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CodePackage.ARRAY_TYPE__SIZE:
return SIZE_EDEFAULT == null ? size != null : !SIZE_EDEFAULT.equals(size);
case CodePackage.ARRAY_TYPE__INDEX_UNIT:
return indexUnit != 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(" (size: "); //$NON-NLS-1$
result.append(size);
result.append(')');
return result.toString();
}
} //ArrayTypeImpl