blob: 077f10c265577baec05692a82a616b6f68d794ff [file] [log] [blame]
/**
* Copyright (c) 2020 CEA LIST.
*
* 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\n\nContributors:
* Arnault Lapitre (CEA LIST) arnault.lapitre@cea.fr
* - Initial API and Implementation
*/
package org.eclipse.efm.ecore.formalml.datatype.impl;
import java.util.Collection;
import org.eclipse.efm.ecore.formalml.datatype.DatatypePackage;
import org.eclipse.efm.ecore.formalml.datatype.EnumerationLiteral;
import org.eclipse.efm.ecore.formalml.datatype.EnumerationType;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Enumeration Type</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.efm.ecore.formalml.datatype.impl.EnumerationTypeImpl#getLiteral <em>Literal</em>}</li>
* <li>{@link org.eclipse.efm.ecore.formalml.datatype.impl.EnumerationTypeImpl#getSuperType <em>Super Type</em>}</li>
* </ul>
*
* @generated
*/
public class EnumerationTypeImpl extends DataTypeImpl implements EnumerationType {
/**
* The cached value of the '{@link #getLiteral() <em>Literal</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLiteral()
* @generated
* @ordered
*/
protected EList<EnumerationLiteral> literal;
/**
* The cached value of the '{@link #getSuperType() <em>Super Type</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSuperType()
* @generated
* @ordered
*/
protected EnumerationType superType;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EnumerationTypeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return DatatypePackage.Literals.ENUMERATION_TYPE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<EnumerationLiteral> getLiteral() {
if (literal == null) {
literal = new EObjectContainmentEList<EnumerationLiteral>(EnumerationLiteral.class, this, DatatypePackage.ENUMERATION_TYPE__LITERAL);
}
return literal;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EnumerationType getSuperType() {
if (superType != null && superType.eIsProxy()) {
InternalEObject oldSuperType = (InternalEObject)superType;
superType = (EnumerationType)eResolveProxy(oldSuperType);
if (superType != oldSuperType) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, DatatypePackage.ENUMERATION_TYPE__SUPER_TYPE, oldSuperType, superType));
}
}
return superType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EnumerationType basicGetSuperType() {
return superType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setSuperType(EnumerationType newSuperType) {
EnumerationType oldSuperType = superType;
superType = newSuperType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DatatypePackage.ENUMERATION_TYPE__SUPER_TYPE, oldSuperType, superType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case DatatypePackage.ENUMERATION_TYPE__LITERAL:
return ((InternalEList<?>)getLiteral()).basicRemove(otherEnd, 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 DatatypePackage.ENUMERATION_TYPE__LITERAL:
return getLiteral();
case DatatypePackage.ENUMERATION_TYPE__SUPER_TYPE:
if (resolve) return getSuperType();
return basicGetSuperType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case DatatypePackage.ENUMERATION_TYPE__LITERAL:
getLiteral().clear();
getLiteral().addAll((Collection<? extends EnumerationLiteral>)newValue);
return;
case DatatypePackage.ENUMERATION_TYPE__SUPER_TYPE:
setSuperType((EnumerationType)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case DatatypePackage.ENUMERATION_TYPE__LITERAL:
getLiteral().clear();
return;
case DatatypePackage.ENUMERATION_TYPE__SUPER_TYPE:
setSuperType((EnumerationType)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case DatatypePackage.ENUMERATION_TYPE__LITERAL:
return literal != null && !literal.isEmpty();
case DatatypePackage.ENUMERATION_TYPE__SUPER_TYPE:
return superType != null;
}
return super.eIsSet(featureID);
}
} //EnumerationTypeImpl