blob: 9cb35956f13775625f01746cf35bd2bcc342afde [file] [log] [blame]
/**
* * Copyright (c) 2006-2010 Istvan Rath and Daniel Varro
* * 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:
* * Istvan Rath, Daniel Varro - initial API and implementation
*
*/
package org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.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.viatra2.gtasmmodel.gtasm.metamodel.asm.core.impl.GTASMElementImpl;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Variable;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.enums.ContainmentMode;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.terms.Term;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.ContainmentConstraint;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.GtPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Containment Constraint</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.impl.ContainmentConstraintImpl#getVariable <em>Variable</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.impl.ContainmentConstraintImpl#getMode <em>Mode</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.impl.ContainmentConstraintImpl#getParent <em>Parent</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ContainmentConstraintImpl extends GTASMElementImpl implements ContainmentConstraint
{
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final String copyright = " * Copyright (c) 2006-2010 Istvan Rath and Daniel Varro\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http://www.eclipse.org/legal/epl-v10.html\r\n *\r\n * Contributors:\r\n * Istvan Rath, Daniel Varro - initial API and implementation\r\n";
/**
* The cached value of the '{@link #getVariable() <em>Variable</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getVariable()
* @generated
* @ordered
*/
protected Variable variable;
/**
* The default value of the '{@link #getMode() <em>Mode</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMode()
* @generated
* @ordered
*/
protected static final ContainmentMode MODE_EDEFAULT = ContainmentMode.IN_LITERAL;
/**
* The cached value of the '{@link #getMode() <em>Mode</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMode()
* @generated
* @ordered
*/
protected ContainmentMode mode = MODE_EDEFAULT;
/**
* The cached value of the '{@link #getParent() <em>Parent</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParent()
* @generated
* @ordered
*/
protected Term parent;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ContainmentConstraintImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return GtPackage.Literals.CONTAINMENT_CONSTRAINT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Variable getVariable()
{
if (variable != null && variable.eIsProxy())
{
InternalEObject oldVariable = (InternalEObject)variable;
variable = (Variable)eResolveProxy(oldVariable);
if (variable != oldVariable)
{
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, GtPackage.CONTAINMENT_CONSTRAINT__VARIABLE, oldVariable, variable));
}
}
return variable;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Variable basicGetVariable()
{
return variable;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setVariable(Variable newVariable)
{
Variable oldVariable = variable;
variable = newVariable;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GtPackage.CONTAINMENT_CONSTRAINT__VARIABLE, oldVariable, variable));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ContainmentMode getMode()
{
return mode;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setMode(ContainmentMode newMode)
{
ContainmentMode oldMode = mode;
mode = newMode == null ? MODE_EDEFAULT : newMode;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GtPackage.CONTAINMENT_CONSTRAINT__MODE, oldMode, mode));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Term getParent()
{
return parent;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetParent(Term newParent, NotificationChain msgs)
{
Term oldParent = parent;
parent = newParent;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GtPackage.CONTAINMENT_CONSTRAINT__PARENT, oldParent, newParent);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setParent(Term newParent)
{
if (newParent != parent)
{
NotificationChain msgs = null;
if (parent != null)
msgs = ((InternalEObject)parent).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GtPackage.CONTAINMENT_CONSTRAINT__PARENT, null, msgs);
if (newParent != null)
msgs = ((InternalEObject)newParent).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GtPackage.CONTAINMENT_CONSTRAINT__PARENT, null, msgs);
msgs = basicSetParent(newParent, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GtPackage.CONTAINMENT_CONSTRAINT__PARENT, newParent, newParent));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case GtPackage.CONTAINMENT_CONSTRAINT__PARENT:
return basicSetParent(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 GtPackage.CONTAINMENT_CONSTRAINT__VARIABLE:
if (resolve) return getVariable();
return basicGetVariable();
case GtPackage.CONTAINMENT_CONSTRAINT__MODE:
return getMode();
case GtPackage.CONTAINMENT_CONSTRAINT__PARENT:
return getParent();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case GtPackage.CONTAINMENT_CONSTRAINT__VARIABLE:
setVariable((Variable)newValue);
return;
case GtPackage.CONTAINMENT_CONSTRAINT__MODE:
setMode((ContainmentMode)newValue);
return;
case GtPackage.CONTAINMENT_CONSTRAINT__PARENT:
setParent((Term)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case GtPackage.CONTAINMENT_CONSTRAINT__VARIABLE:
setVariable((Variable)null);
return;
case GtPackage.CONTAINMENT_CONSTRAINT__MODE:
setMode(MODE_EDEFAULT);
return;
case GtPackage.CONTAINMENT_CONSTRAINT__PARENT:
setParent((Term)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case GtPackage.CONTAINMENT_CONSTRAINT__VARIABLE:
return variable != null;
case GtPackage.CONTAINMENT_CONSTRAINT__MODE:
return mode != MODE_EDEFAULT;
case GtPackage.CONTAINMENT_CONSTRAINT__PARENT:
return parent != 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(" (mode: ");
result.append(mode);
result.append(')');
return result.toString();
}
} //ContainmentConstraintImpl