blob: 51c8b6deef153dab7883b8c2b0ced9d17b17b557 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010, 2019 Willink Transformations and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* E.D.Willink - Initial API and implementation
*******************************************************************************/
package org.eclipse.ocl.pivot.internal;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.Map;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.DiagnosticChain;
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.jdt.annotation.NonNull;
import org.eclipse.ocl.pivot.Comment;
import org.eclipse.ocl.pivot.Element;
import org.eclipse.ocl.pivot.ElementExtension;
import org.eclipse.ocl.pivot.PivotPackage;
import org.eclipse.ocl.pivot.ReferringElement;
import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.TypeExp;
import org.eclipse.ocl.pivot.ValueSpecification;
import org.eclipse.ocl.pivot.util.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Type Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.pivot.internal.TypeExpImpl#getReferredType <em>Referred Type</em>}</li>
* </ul>
*
* @generated
*/
public class TypeExpImpl
extends OCLExpressionImpl
implements TypeExp {
/**
* The number of structural features of the '<em>Type Exp</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int TYPE_EXP_FEATURE_COUNT = OCLExpressionImpl.OCL_EXPRESSION_FEATURE_COUNT + 1;
/**
* The number of operations of the '<em>Type Exp</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int TYPE_EXP_OPERATION_COUNT = OCLExpressionImpl.OCL_EXPRESSION_OPERATION_COUNT + 1;
/**
* The cached value of the '{@link #getReferredType() <em>Referred Type</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getReferredType()
* @generated
* @ordered
*/
protected Type referredType;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TypeExpImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return PivotPackage.Literals.TYPE_EXP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Type getReferredType() {
if (referredType != null && referredType.eIsProxy())
{
InternalEObject oldReferredType = (InternalEObject)referredType;
referredType = (Type)eResolveProxy(oldReferredType);
if (referredType != oldReferredType)
{
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, 9, oldReferredType, referredType));
}
}
return referredType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Type basicGetReferredType() {
return referredType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setReferredType(Type newReferredType) {
Type oldReferredType = referredType;
referredType = newReferredType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, 9, oldReferredType, referredType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID)
{
case 0:
return getAnnotatingComments();
case 1:
return getOwnedAnnotations();
case 2:
return getOwnedComments();
case 3:
return getOwnedExtensions();
case 4:
return getName();
case 5:
return isIsMany();
case 6:
return isIsRequired();
case 7:
if (resolve) return getType();
return basicGetType();
case 8:
return getTypeValue();
case 9:
if (resolve) return getReferredType();
return basicGetReferredType();
}
return eDynamicGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID)
{
case 0:
getAnnotatingComments().clear();
getAnnotatingComments().addAll((Collection<? extends Comment>)newValue);
return;
case 1:
getOwnedAnnotations().clear();
getOwnedAnnotations().addAll((Collection<? extends Element>)newValue);
return;
case 2:
getOwnedComments().clear();
getOwnedComments().addAll((Collection<? extends Comment>)newValue);
return;
case 3:
getOwnedExtensions().clear();
getOwnedExtensions().addAll((Collection<? extends ElementExtension>)newValue);
return;
case 4:
setName((String)newValue);
return;
case 6:
setIsRequired((Boolean)newValue);
return;
case 7:
setType((Type)newValue);
return;
case 8:
setTypeValue((Type)newValue);
return;
case 9:
setReferredType((Type)newValue);
return;
}
eDynamicSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID)
{
case 0:
getAnnotatingComments().clear();
return;
case 1:
getOwnedAnnotations().clear();
return;
case 2:
getOwnedComments().clear();
return;
case 3:
getOwnedExtensions().clear();
return;
case 4:
setName(NAME_EDEFAULT);
return;
case 6:
setIsRequired(IS_REQUIRED_EDEFAULT);
return;
case 7:
setType((Type)null);
return;
case 8:
setTypeValue((Type)null);
return;
case 9:
setReferredType((Type)null);
return;
}
eDynamicUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID)
{
case 0:
return annotatingComments != null && !annotatingComments.isEmpty();
case 1:
return ownedAnnotations != null && !ownedAnnotations.isEmpty();
case 2:
return ownedComments != null && !ownedComments.isEmpty();
case 3:
return ownedExtensions != null && !ownedExtensions.isEmpty();
case 4:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case 5:
return isIsMany() != IS_MANY_EDEFAULT;
case 6:
return ((eFlags & IS_REQUIRED_EFLAG) != 0) != IS_REQUIRED_EDEFAULT;
case 7:
return type != null;
case 8:
return typeValue != null;
case 9:
return referredType != null;
}
return eDynamicIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eDerivedOperationID(int baseOperationID, Class<?> baseClass)
{
if (baseClass == ReferringElement.class)
{
switch (baseOperationID)
{
case 0: return 6;
default: return -1;
}
}
return super.eDerivedOperationID(baseOperationID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@SuppressWarnings("unchecked")
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException
{
switch (operationID)
{
case 0:
return allOwnedElements();
case 1:
return getValue((Type)arguments.get(0), (String)arguments.get(1));
case 2:
return CompatibleBody((ValueSpecification)arguments.get(0));
case 3:
return isNonNull();
case 4:
return isNull();
case 5:
return validateTypeIsNotNull((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1));
case 6:
return getReferredElement();
}
return eDynamicInvoke(operationID, arguments);
}
@Override
public <R> R accept(@NonNull Visitor<R> visitor) {
return visitor.visitTypeExp(this);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public Element getReferredElement()
{
return getReferredType();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public Type getTypeValue() {
return getReferredType();
}
} //TypeExpImpl