blob: 4117b829c072b633687be3328e999df01d787fe6 [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.asm.definitions.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.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.ASMFunction;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.DefinitionsPackage;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Machine;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Module;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Rule;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.GTRule;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.GtPackage;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.impl.PatternContainerImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Machine</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.MachineImpl#getMainRule <em>Main Rule</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.MachineImpl#getGtRuleDefinitions <em>Gt Rule Definitions</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.MachineImpl#getAsmFunctionDefinitions <em>Asm Function Definitions</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.MachineImpl#getAsmRuleDefinitions <em>Asm Rule Definitions</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.MachineImpl#getModule <em>Module</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class MachineImpl extends PatternContainerImpl implements Machine
{
/**
* <!-- 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 #getMainRule() <em>Main Rule</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMainRule()
* @generated
* @ordered
*/
protected Rule mainRule;
/**
* The cached value of the '{@link #getGtRuleDefinitions() <em>Gt Rule Definitions</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getGtRuleDefinitions()
* @generated
* @ordered
*/
protected EList<GTRule> gtRuleDefinitions;
/**
* The cached value of the '{@link #getAsmFunctionDefinitions() <em>Asm Function Definitions</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAsmFunctionDefinitions()
* @generated
* @ordered
*/
protected EList<ASMFunction> asmFunctionDefinitions;
/**
* The cached value of the '{@link #getAsmRuleDefinitions() <em>Asm Rule Definitions</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAsmRuleDefinitions()
* @generated
* @ordered
*/
protected EList<Rule> asmRuleDefinitions;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MachineImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return DefinitionsPackage.Literals.MACHINE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Rule getMainRule()
{
if (mainRule != null && mainRule.eIsProxy())
{
InternalEObject oldMainRule = (InternalEObject)mainRule;
mainRule = (Rule)eResolveProxy(oldMainRule);
if (mainRule != oldMainRule)
{
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, DefinitionsPackage.MACHINE__MAIN_RULE, oldMainRule, mainRule));
}
}
return mainRule;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Rule basicGetMainRule()
{
return mainRule;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setMainRule(Rule newMainRule)
{
Rule oldMainRule = mainRule;
mainRule = newMainRule;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.MACHINE__MAIN_RULE, oldMainRule, mainRule));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<GTRule> getGtRuleDefinitions()
{
if (gtRuleDefinitions == null)
{
gtRuleDefinitions = new EObjectContainmentWithInverseEList<GTRule>(GTRule.class, this, DefinitionsPackage.MACHINE__GT_RULE_DEFINITIONS, GtPackage.GT_RULE__NAMESPACE);
}
return gtRuleDefinitions;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<ASMFunction> getAsmFunctionDefinitions()
{
if (asmFunctionDefinitions == null)
{
asmFunctionDefinitions = new EObjectContainmentWithInverseEList<ASMFunction>(ASMFunction.class, this, DefinitionsPackage.MACHINE__ASM_FUNCTION_DEFINITIONS, DefinitionsPackage.ASM_FUNCTION__NAMESPACE);
}
return asmFunctionDefinitions;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Rule> getAsmRuleDefinitions()
{
if (asmRuleDefinitions == null)
{
asmRuleDefinitions = new EObjectContainmentWithInverseEList<Rule>(Rule.class, this, DefinitionsPackage.MACHINE__ASM_RULE_DEFINITIONS, DefinitionsPackage.RULE__NAMESPACE);
}
return asmRuleDefinitions;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Module getModule()
{
if (eContainerFeatureID() != DefinitionsPackage.MACHINE__MODULE) return null;
return (Module)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetModule(Module newModule, NotificationChain msgs)
{
msgs = eBasicSetContainer((InternalEObject)newModule, DefinitionsPackage.MACHINE__MODULE, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setModule(Module newModule)
{
if (newModule != eInternalContainer() || (eContainerFeatureID() != DefinitionsPackage.MACHINE__MODULE && newModule != null))
{
if (EcoreUtil.isAncestor(this, newModule))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newModule != null)
msgs = ((InternalEObject)newModule).eInverseAdd(this, DefinitionsPackage.MODULE__MACHINE, Module.class, msgs);
msgs = basicSetModule(newModule, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.MACHINE__MODULE, newModule, newModule));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case DefinitionsPackage.MACHINE__GT_RULE_DEFINITIONS:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getGtRuleDefinitions()).basicAdd(otherEnd, msgs);
case DefinitionsPackage.MACHINE__ASM_FUNCTION_DEFINITIONS:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getAsmFunctionDefinitions()).basicAdd(otherEnd, msgs);
case DefinitionsPackage.MACHINE__ASM_RULE_DEFINITIONS:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getAsmRuleDefinitions()).basicAdd(otherEnd, msgs);
case DefinitionsPackage.MACHINE__MODULE:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetModule((Module)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 DefinitionsPackage.MACHINE__GT_RULE_DEFINITIONS:
return ((InternalEList<?>)getGtRuleDefinitions()).basicRemove(otherEnd, msgs);
case DefinitionsPackage.MACHINE__ASM_FUNCTION_DEFINITIONS:
return ((InternalEList<?>)getAsmFunctionDefinitions()).basicRemove(otherEnd, msgs);
case DefinitionsPackage.MACHINE__ASM_RULE_DEFINITIONS:
return ((InternalEList<?>)getAsmRuleDefinitions()).basicRemove(otherEnd, msgs);
case DefinitionsPackage.MACHINE__MODULE:
return basicSetModule(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs)
{
switch (eContainerFeatureID())
{
case DefinitionsPackage.MACHINE__MODULE:
return eInternalContainer().eInverseRemove(this, DefinitionsPackage.MODULE__MACHINE, Module.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 DefinitionsPackage.MACHINE__MAIN_RULE:
if (resolve) return getMainRule();
return basicGetMainRule();
case DefinitionsPackage.MACHINE__GT_RULE_DEFINITIONS:
return getGtRuleDefinitions();
case DefinitionsPackage.MACHINE__ASM_FUNCTION_DEFINITIONS:
return getAsmFunctionDefinitions();
case DefinitionsPackage.MACHINE__ASM_RULE_DEFINITIONS:
return getAsmRuleDefinitions();
case DefinitionsPackage.MACHINE__MODULE:
return getModule();
}
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 DefinitionsPackage.MACHINE__MAIN_RULE:
setMainRule((Rule)newValue);
return;
case DefinitionsPackage.MACHINE__GT_RULE_DEFINITIONS:
getGtRuleDefinitions().clear();
getGtRuleDefinitions().addAll((Collection<? extends GTRule>)newValue);
return;
case DefinitionsPackage.MACHINE__ASM_FUNCTION_DEFINITIONS:
getAsmFunctionDefinitions().clear();
getAsmFunctionDefinitions().addAll((Collection<? extends ASMFunction>)newValue);
return;
case DefinitionsPackage.MACHINE__ASM_RULE_DEFINITIONS:
getAsmRuleDefinitions().clear();
getAsmRuleDefinitions().addAll((Collection<? extends Rule>)newValue);
return;
case DefinitionsPackage.MACHINE__MODULE:
setModule((Module)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case DefinitionsPackage.MACHINE__MAIN_RULE:
setMainRule((Rule)null);
return;
case DefinitionsPackage.MACHINE__GT_RULE_DEFINITIONS:
getGtRuleDefinitions().clear();
return;
case DefinitionsPackage.MACHINE__ASM_FUNCTION_DEFINITIONS:
getAsmFunctionDefinitions().clear();
return;
case DefinitionsPackage.MACHINE__ASM_RULE_DEFINITIONS:
getAsmRuleDefinitions().clear();
return;
case DefinitionsPackage.MACHINE__MODULE:
setModule((Module)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case DefinitionsPackage.MACHINE__MAIN_RULE:
return mainRule != null;
case DefinitionsPackage.MACHINE__GT_RULE_DEFINITIONS:
return gtRuleDefinitions != null && !gtRuleDefinitions.isEmpty();
case DefinitionsPackage.MACHINE__ASM_FUNCTION_DEFINITIONS:
return asmFunctionDefinitions != null && !asmFunctionDefinitions.isEmpty();
case DefinitionsPackage.MACHINE__ASM_RULE_DEFINITIONS:
return asmRuleDefinitions != null && !asmRuleDefinitions.isEmpty();
case DefinitionsPackage.MACHINE__MODULE:
return getModule() != null;
}
return super.eIsSet(featureID);
}
} //MachineImpl