blob: ac183300f1ec4b6e9d3260f2f35e8d66b68473d7 [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 java.util.Collection;
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.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.core.impl.GTASMElementImpl;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Machine;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.GTPattern;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.GTPatternBody;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.GtPackage;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.PatternContainer;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.PatternVariable;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>GT Pattern</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.impl.GTPatternImpl#getSymParameters <em>Sym Parameters</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.impl.GTPatternImpl#getPatternBodies <em>Pattern Bodies</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.impl.GTPatternImpl#getNamespace <em>Namespace</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.impl.GTPatternImpl#isDistinctMatching <em>Distinct Matching</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.impl.GTPatternImpl#getContainer <em>Container</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class GTPatternImpl extends GTASMElementImpl implements GTPattern
{
/**
* <!-- 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 #getSymParameters() <em>Sym Parameters</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSymParameters()
* @generated
* @ordered
*/
protected EList<PatternVariable> symParameters;
/**
* The cached value of the '{@link #getPatternBodies() <em>Pattern Bodies</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPatternBodies()
* @generated
* @ordered
*/
protected EList<GTPatternBody> patternBodies;
/**
* The cached value of the '{@link #getNamespace() <em>Namespace</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getNamespace()
* @generated
* @ordered
*/
protected Machine namespace;
/**
* The default value of the '{@link #isDistinctMatching() <em>Distinct Matching</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isDistinctMatching()
* @generated
* @ordered
*/
protected static final boolean DISTINCT_MATCHING_EDEFAULT = true;
/**
* The cached value of the '{@link #isDistinctMatching() <em>Distinct Matching</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isDistinctMatching()
* @generated
* @ordered
*/
protected boolean distinctMatching = DISTINCT_MATCHING_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected GTPatternImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return GtPackage.Literals.GT_PATTERN;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<PatternVariable> getSymParameters()
{
if (symParameters == null)
{
symParameters = new EObjectContainmentEList<PatternVariable>(PatternVariable.class, this, GtPackage.GT_PATTERN__SYM_PARAMETERS);
}
return symParameters;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<GTPatternBody> getPatternBodies()
{
if (patternBodies == null)
{
patternBodies = new EObjectContainmentWithInverseEList<GTPatternBody>(GTPatternBody.class, this, GtPackage.GT_PATTERN__PATTERN_BODIES, GtPackage.GT_PATTERN_BODY__HEADER);
}
return patternBodies;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Machine getNamespace()
{
if (namespace != null && namespace.eIsProxy())
{
InternalEObject oldNamespace = (InternalEObject)namespace;
namespace = (Machine)eResolveProxy(oldNamespace);
if (namespace != oldNamespace)
{
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, GtPackage.GT_PATTERN__NAMESPACE, oldNamespace, namespace));
}
}
return namespace;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Machine basicGetNamespace()
{
return namespace;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setNamespace(Machine newNamespace)
{
Machine oldNamespace = namespace;
namespace = newNamespace;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GtPackage.GT_PATTERN__NAMESPACE, oldNamespace, namespace));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isDistinctMatching()
{
return distinctMatching;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setDistinctMatching(boolean newDistinctMatching)
{
boolean oldDistinctMatching = distinctMatching;
distinctMatching = newDistinctMatching;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GtPackage.GT_PATTERN__DISTINCT_MATCHING, oldDistinctMatching, distinctMatching));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public PatternContainer getContainer()
{
if (eContainerFeatureID() != GtPackage.GT_PATTERN__CONTAINER) return null;
return (PatternContainer)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetContainer(PatternContainer newContainer, NotificationChain msgs)
{
msgs = eBasicSetContainer((InternalEObject)newContainer, GtPackage.GT_PATTERN__CONTAINER, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setContainer(PatternContainer newContainer)
{
if (newContainer != eInternalContainer() || (eContainerFeatureID() != GtPackage.GT_PATTERN__CONTAINER && newContainer != null))
{
if (EcoreUtil.isAncestor(this, newContainer))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newContainer != null)
msgs = ((InternalEObject)newContainer).eInverseAdd(this, GtPackage.PATTERN_CONTAINER__GT_PATTERN_DEFINITIONS, PatternContainer.class, msgs);
msgs = basicSetContainer(newContainer, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GtPackage.GT_PATTERN__CONTAINER, newContainer, newContainer));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case GtPackage.GT_PATTERN__PATTERN_BODIES:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getPatternBodies()).basicAdd(otherEnd, msgs);
case GtPackage.GT_PATTERN__CONTAINER:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetContainer((PatternContainer)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case GtPackage.GT_PATTERN__SYM_PARAMETERS:
return ((InternalEList<?>)getSymParameters()).basicRemove(otherEnd, msgs);
case GtPackage.GT_PATTERN__PATTERN_BODIES:
return ((InternalEList<?>)getPatternBodies()).basicRemove(otherEnd, msgs);
case GtPackage.GT_PATTERN__CONTAINER:
return basicSetContainer(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs)
{
switch (eContainerFeatureID())
{
case GtPackage.GT_PATTERN__CONTAINER:
return eInternalContainer().eInverseRemove(this, GtPackage.PATTERN_CONTAINER__GT_PATTERN_DEFINITIONS, PatternContainer.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
switch (featureID)
{
case GtPackage.GT_PATTERN__SYM_PARAMETERS:
return getSymParameters();
case GtPackage.GT_PATTERN__PATTERN_BODIES:
return getPatternBodies();
case GtPackage.GT_PATTERN__NAMESPACE:
if (resolve) return getNamespace();
return basicGetNamespace();
case GtPackage.GT_PATTERN__DISTINCT_MATCHING:
return isDistinctMatching();
case GtPackage.GT_PATTERN__CONTAINER:
return getContainer();
}
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 GtPackage.GT_PATTERN__SYM_PARAMETERS:
getSymParameters().clear();
getSymParameters().addAll((Collection<? extends PatternVariable>)newValue);
return;
case GtPackage.GT_PATTERN__PATTERN_BODIES:
getPatternBodies().clear();
getPatternBodies().addAll((Collection<? extends GTPatternBody>)newValue);
return;
case GtPackage.GT_PATTERN__NAMESPACE:
setNamespace((Machine)newValue);
return;
case GtPackage.GT_PATTERN__DISTINCT_MATCHING:
setDistinctMatching((Boolean)newValue);
return;
case GtPackage.GT_PATTERN__CONTAINER:
setContainer((PatternContainer)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case GtPackage.GT_PATTERN__SYM_PARAMETERS:
getSymParameters().clear();
return;
case GtPackage.GT_PATTERN__PATTERN_BODIES:
getPatternBodies().clear();
return;
case GtPackage.GT_PATTERN__NAMESPACE:
setNamespace((Machine)null);
return;
case GtPackage.GT_PATTERN__DISTINCT_MATCHING:
setDistinctMatching(DISTINCT_MATCHING_EDEFAULT);
return;
case GtPackage.GT_PATTERN__CONTAINER:
setContainer((PatternContainer)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case GtPackage.GT_PATTERN__SYM_PARAMETERS:
return symParameters != null && !symParameters.isEmpty();
case GtPackage.GT_PATTERN__PATTERN_BODIES:
return patternBodies != null && !patternBodies.isEmpty();
case GtPackage.GT_PATTERN__NAMESPACE:
return namespace != null;
case GtPackage.GT_PATTERN__DISTINCT_MATCHING:
return distinctMatching != DISTINCT_MATCHING_EDEFAULT;
case GtPackage.GT_PATTERN__CONTAINER:
return getContainer() != 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(" (distinctMatching: ");
result.append(distinctMatching);
result.append(')');
return result.toString();
}
} //GTPatternImpl