blob: f2ee18726803cbb1ce60c10049440866cafa0983 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2015 ALL4TEC & 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
*
* Contributors:
* ALL4TEC & CEA LIST - initial API and implementation
******************************************************************************/
package org.polarsys.esf.esfarchitectureconcepts.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.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.polarsys.esf.esfarchitectureconcepts.IESFArchitectureConceptsPackage;
import org.polarsys.esf.esfarchitectureconcepts.ISBlock;
import org.polarsys.esf.esfarchitectureconcepts.ISConnector;
import org.polarsys.esf.esfarchitectureconcepts.ISModel;
import org.polarsys.esf.esfarchitectureconcepts.ISPart;
import org.polarsys.esf.esfarchitectureconcepts.ISPort;
import org.polarsys.esf.esfarchitectureconcepts.ISPortRole;
import org.polarsys.esf.esfcore.impl.AbstractSArchitectureElement;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>SBlock</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.polarsys.esf.esfarchitectureconcepts.impl.SBlock#getBase_Class <em>Base Class</em>}</li>
* <li>{@link org.polarsys.esf.esfarchitectureconcepts.impl.SBlock#isTopBlock <em>Top Block</em>}</li>
* <li>{@link org.polarsys.esf.esfarchitectureconcepts.impl.SBlock#getOwnedSParts <em>Owned SParts</em>}</li>
* <li>{@link org.polarsys.esf.esfarchitectureconcepts.impl.SBlock#getUsages <em>Usages</em>}</li>
* <li>{@link org.polarsys.esf.esfarchitectureconcepts.impl.SBlock#getOwnedSPortRoles <em>Owned SPort Roles</em>}</li>
* <li>{@link org.polarsys.esf.esfarchitectureconcepts.impl.SBlock#getOwnedSPorts <em>Owned SPorts</em>}</li>
* <li>{@link org.polarsys.esf.esfarchitectureconcepts.impl.SBlock#getSModel <em>SModel</em>}</li>
* <li>{@link org.polarsys.esf.esfarchitectureconcepts.impl.SBlock#getSConnectorsList <em>SConnectors List</em>}</li>
* </ul>
*
* @generated
*/
public class SBlock
extends AbstractSArchitectureElement
implements ISBlock {
/**
* The cached value of the '{@link #getBase_Class() <em>Base Class</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getBase_Class()
* @generated
* @ordered
*/
protected org.eclipse.uml2.uml.Class base_Class;
/**
* The default value of the '{@link #isTopBlock() <em>Top Block</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #isTopBlock()
* @generated
* @ordered
*/
protected static final boolean TOP_BLOCK_EDEFAULT = false;
/**
* The cached value of the '{@link #getOwnedSParts() <em>Owned SParts</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getOwnedSParts()
* @generated
* @ordered
*/
protected EList<ISPart> ownedSParts;
/**
* The cached value of the '{@link #getUsages() <em>Usages</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getUsages()
* @generated
* @ordered
*/
protected EList<ISPart> usages;
/**
* The cached value of the '{@link #getOwnedSPortRoles() <em>Owned SPort Roles</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getOwnedSPortRoles()
* @generated
* @ordered
*/
protected EList<ISPortRole> ownedSPortRoles;
/**
* The cached value of the '{@link #getOwnedSPorts() <em>Owned SPorts</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getOwnedSPorts()
* @generated
* @ordered
*/
protected EList<ISPort> ownedSPorts;
/**
* The cached value of the '{@link #getSConnectorsList() <em>SConnectors List</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getSConnectorsList()
* @generated
* @ordered
*/
protected EList<ISConnector> sConnectorsList;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected SBlock() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return IESFArchitectureConceptsPackage.Literals.SBLOCK;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public org.eclipse.uml2.uml.Class getBase_Class() {
if (base_Class != null && base_Class.eIsProxy()) {
InternalEObject oldBase_Class = (InternalEObject) base_Class;
base_Class = (org.eclipse.uml2.uml.Class) eResolveProxy(oldBase_Class);
if (base_Class != oldBase_Class) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(
this,
Notification.RESOLVE,
IESFArchitectureConceptsPackage.SBLOCK__BASE_CLASS,
oldBase_Class,
base_Class));
}
}
return base_Class;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public org.eclipse.uml2.uml.Class basicGetBase_Class() {
return base_Class;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public void setBase_Class(org.eclipse.uml2.uml.Class newBase_Class) {
org.eclipse.uml2.uml.Class oldBase_Class = base_Class;
base_Class = newBase_Class;
if (eNotificationRequired())
eNotify(new ENotificationImpl(
this,
Notification.SET,
IESFArchitectureConceptsPackage.SBLOCK__BASE_CLASS,
oldBase_Class,
base_Class));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public boolean isTopBlock() {
// TODO: implement this method to return the 'Top Block' attribute
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public void setTopBlock(boolean newTopBlock) {
// TODO: implement this method to set the 'Top Block' attribute
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public EList<ISPart> getOwnedSParts() {
if (ownedSParts == null) {
ownedSParts = new EObjectContainmentWithInverseEList.Resolving<ISPart>(
ISPart.class,
this,
IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPARTS,
IESFArchitectureConceptsPackage.SPART__OWNER);
}
return ownedSParts;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public EList<ISPart> getUsages() {
if (usages == null) {
usages = new EObjectWithInverseResolvingEList<ISPart>(
ISPart.class,
this,
IESFArchitectureConceptsPackage.SBLOCK__USAGES,
IESFArchitectureConceptsPackage.SPART__TYPE);
}
return usages;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public EList<ISPortRole> getOwnedSPortRoles() {
if (ownedSPortRoles == null) {
ownedSPortRoles = new EObjectContainmentWithInverseEList.Resolving<ISPortRole>(
ISPortRole.class,
this,
IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORT_ROLES,
IESFArchitectureConceptsPackage.SPORT_ROLE__OWNER);
}
return ownedSPortRoles;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public EList<ISPort> getOwnedSPorts() {
if (ownedSPorts == null) {
ownedSPorts = new EObjectContainmentWithInverseEList.Resolving<ISPort>(
ISPort.class,
this,
IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORTS,
IESFArchitectureConceptsPackage.SPORT__OWNER);
}
return ownedSPorts;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public ISModel getSModel() {
if (eContainerFeatureID() != IESFArchitectureConceptsPackage.SBLOCK__SMODEL)
return null;
return (ISModel) eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public ISModel basicGetSModel() {
if (eContainerFeatureID() != IESFArchitectureConceptsPackage.SBLOCK__SMODEL)
return null;
return (ISModel) eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetSModel(ISModel newSModel, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject) newSModel, IESFArchitectureConceptsPackage.SBLOCK__SMODEL, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public void setSModel(ISModel newSModel) {
if (newSModel != eInternalContainer()
|| (eContainerFeatureID() != IESFArchitectureConceptsPackage.SBLOCK__SMODEL && newSModel != null)) {
if (EcoreUtil.isAncestor(this, newSModel))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newSModel != null)
msgs = ((InternalEObject) newSModel)
.eInverseAdd(this, IESFArchitectureConceptsPackage.SMODEL__ONWED_SBLOCKS, ISModel.class, msgs);
msgs = basicSetSModel(newSModel, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(
this,
Notification.SET,
IESFArchitectureConceptsPackage.SBLOCK__SMODEL,
newSModel,
newSModel));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public EList<ISConnector> getSConnectorsList() {
if (sConnectorsList == null) {
sConnectorsList = new EObjectContainmentWithInverseEList.Resolving<ISConnector>(
ISConnector.class,
this,
IESFArchitectureConceptsPackage.SBLOCK__SCONNECTORS_LIST,
IESFArchitectureConceptsPackage.SCONNECTOR__OWNER);
}
return sConnectorsList;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPARTS:
return ((InternalEList<InternalEObject>) (InternalEList<?>) getOwnedSParts()).basicAdd(otherEnd, msgs);
case IESFArchitectureConceptsPackage.SBLOCK__USAGES:
return ((InternalEList<InternalEObject>) (InternalEList<?>) getUsages()).basicAdd(otherEnd, msgs);
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORT_ROLES:
return ((InternalEList<InternalEObject>) (InternalEList<?>) getOwnedSPortRoles()).basicAdd(
otherEnd,
msgs);
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORTS:
return ((InternalEList<InternalEObject>) (InternalEList<?>) getOwnedSPorts()).basicAdd(otherEnd, msgs);
case IESFArchitectureConceptsPackage.SBLOCK__SMODEL:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetSModel((ISModel) otherEnd, msgs);
case IESFArchitectureConceptsPackage.SBLOCK__SCONNECTORS_LIST:
return ((InternalEList<InternalEObject>) (InternalEList<?>) getSConnectorsList()).basicAdd(
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 IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPARTS:
return ((InternalEList<?>) getOwnedSParts()).basicRemove(otherEnd, msgs);
case IESFArchitectureConceptsPackage.SBLOCK__USAGES:
return ((InternalEList<?>) getUsages()).basicRemove(otherEnd, msgs);
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORT_ROLES:
return ((InternalEList<?>) getOwnedSPortRoles()).basicRemove(otherEnd, msgs);
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORTS:
return ((InternalEList<?>) getOwnedSPorts()).basicRemove(otherEnd, msgs);
case IESFArchitectureConceptsPackage.SBLOCK__SMODEL:
return basicSetSModel(null, msgs);
case IESFArchitectureConceptsPackage.SBLOCK__SCONNECTORS_LIST:
return ((InternalEList<?>) getSConnectorsList()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case IESFArchitectureConceptsPackage.SBLOCK__SMODEL:
return eInternalContainer().eInverseRemove(
this,
IESFArchitectureConceptsPackage.SMODEL__ONWED_SBLOCKS,
ISModel.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 IESFArchitectureConceptsPackage.SBLOCK__BASE_CLASS:
if (resolve)
return getBase_Class();
return basicGetBase_Class();
case IESFArchitectureConceptsPackage.SBLOCK__TOP_BLOCK:
return isTopBlock();
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPARTS:
return getOwnedSParts();
case IESFArchitectureConceptsPackage.SBLOCK__USAGES:
return getUsages();
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORT_ROLES:
return getOwnedSPortRoles();
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORTS:
return getOwnedSPorts();
case IESFArchitectureConceptsPackage.SBLOCK__SMODEL:
if (resolve)
return getSModel();
return basicGetSModel();
case IESFArchitectureConceptsPackage.SBLOCK__SCONNECTORS_LIST:
return getSConnectorsList();
}
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 IESFArchitectureConceptsPackage.SBLOCK__BASE_CLASS:
setBase_Class((org.eclipse.uml2.uml.Class) newValue);
return;
case IESFArchitectureConceptsPackage.SBLOCK__TOP_BLOCK:
setTopBlock((Boolean) newValue);
return;
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPARTS:
getOwnedSParts().clear();
getOwnedSParts().addAll((Collection<? extends ISPart>) newValue);
return;
case IESFArchitectureConceptsPackage.SBLOCK__USAGES:
getUsages().clear();
getUsages().addAll((Collection<? extends ISPart>) newValue);
return;
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORT_ROLES:
getOwnedSPortRoles().clear();
getOwnedSPortRoles().addAll((Collection<? extends ISPortRole>) newValue);
return;
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORTS:
getOwnedSPorts().clear();
getOwnedSPorts().addAll((Collection<? extends ISPort>) newValue);
return;
case IESFArchitectureConceptsPackage.SBLOCK__SMODEL:
setSModel((ISModel) newValue);
return;
case IESFArchitectureConceptsPackage.SBLOCK__SCONNECTORS_LIST:
getSConnectorsList().clear();
getSConnectorsList().addAll((Collection<? extends ISConnector>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case IESFArchitectureConceptsPackage.SBLOCK__BASE_CLASS:
setBase_Class((org.eclipse.uml2.uml.Class) null);
return;
case IESFArchitectureConceptsPackage.SBLOCK__TOP_BLOCK:
setTopBlock(TOP_BLOCK_EDEFAULT);
return;
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPARTS:
getOwnedSParts().clear();
return;
case IESFArchitectureConceptsPackage.SBLOCK__USAGES:
getUsages().clear();
return;
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORT_ROLES:
getOwnedSPortRoles().clear();
return;
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORTS:
getOwnedSPorts().clear();
return;
case IESFArchitectureConceptsPackage.SBLOCK__SMODEL:
setSModel((ISModel) null);
return;
case IESFArchitectureConceptsPackage.SBLOCK__SCONNECTORS_LIST:
getSConnectorsList().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case IESFArchitectureConceptsPackage.SBLOCK__BASE_CLASS:
return base_Class != null;
case IESFArchitectureConceptsPackage.SBLOCK__TOP_BLOCK:
return isTopBlock() != TOP_BLOCK_EDEFAULT;
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPARTS:
return ownedSParts != null && !ownedSParts.isEmpty();
case IESFArchitectureConceptsPackage.SBLOCK__USAGES:
return usages != null && !usages.isEmpty();
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORT_ROLES:
return ownedSPortRoles != null && !ownedSPortRoles.isEmpty();
case IESFArchitectureConceptsPackage.SBLOCK__OWNED_SPORTS:
return ownedSPorts != null && !ownedSPorts.isEmpty();
case IESFArchitectureConceptsPackage.SBLOCK__SMODEL:
return basicGetSModel() != null;
case IESFArchitectureConceptsPackage.SBLOCK__SCONNECTORS_LIST:
return sConnectorsList != null && !sConnectorsList.isEmpty();
}
return super.eIsSet(featureID);
}
} // SBlock