/**
*/
package genericbcm.impl;
import genericbcm.FailureEffect;
import genericbcm.GenericbcmPackage;
import genericbcm.RiskCategory;
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.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Risk Category</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link genericbcm.impl.RiskCategoryImpl#getSubCategories <em>Sub Categories</em>}</li>
* <li>{@link genericbcm.impl.RiskCategoryImpl#getParentCategory <em>Parent Category</em>}</li>
* <li>{@link genericbcm.impl.RiskCategoryImpl#getHasRisks <em>Has Risks</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class RiskCategoryImpl extends NameableImpl implements RiskCategory {
/**
* The cached value of the '{@link #getSubCategories() <em>Sub Categories</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSubCategories()
* @generated
* @ordered
*/
protected EList<RiskCategory> subCategories;
/**
* The cached value of the '{@link #getParentCategory() <em>Parent Category</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParentCategory()
* @generated
* @ordered
*/
protected RiskCategory parentCategory;
/**
* The cached value of the '{@link #getHasRisks() <em>Has Risks</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getHasRisks()
* @generated
* @ordered
*/
protected EList<FailureEffect> hasRisks;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected RiskCategoryImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return GenericbcmPackage.Literals.RISK_CATEGORY;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<RiskCategory> getSubCategories() {
if (subCategories == null) {
subCategories = new EObjectWithInverseResolvingEList<RiskCategory>(RiskCategory.class, this, GenericbcmPackage.RISK_CATEGORY__SUB_CATEGORIES, GenericbcmPackage.RISK_CATEGORY__PARENT_CATEGORY);
}
return subCategories;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public RiskCategory getParentCategory() {
if (parentCategory != null && parentCategory.eIsProxy()) {
InternalEObject oldParentCategory = (InternalEObject)parentCategory;
parentCategory = (RiskCategory)eResolveProxy(oldParentCategory);
if (parentCategory != oldParentCategory) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, GenericbcmPackage.RISK_CATEGORY__PARENT_CATEGORY, oldParentCategory, parentCategory));
}
}
return parentCategory;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public RiskCategory basicGetParentCategory() {
return parentCategory;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetParentCategory(RiskCategory newParentCategory, NotificationChain msgs) {
RiskCategory oldParentCategory = parentCategory;
parentCategory = newParentCategory;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GenericbcmPackage.RISK_CATEGORY__PARENT_CATEGORY, oldParentCategory, newParentCategory);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setParentCategory(RiskCategory newParentCategory) {
if (newParentCategory != parentCategory) {
NotificationChain msgs = null;
if (parentCategory != null)
msgs = ((InternalEObject)parentCategory).eInverseRemove(this, GenericbcmPackage.RISK_CATEGORY__SUB_CATEGORIES, RiskCategory.class, msgs);
if (newParentCategory != null)
msgs = ((InternalEObject)newParentCategory).eInverseAdd(this, GenericbcmPackage.RISK_CATEGORY__SUB_CATEGORIES, RiskCategory.class, msgs);
msgs = basicSetParentCategory(newParentCategory, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GenericbcmPackage.RISK_CATEGORY__PARENT_CATEGORY, newParentCategory, newParentCategory));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<FailureEffect> getHasRisks() {
if (hasRisks == null) {
hasRisks = new EObjectResolvingEList<FailureEffect>(FailureEffect.class, this, GenericbcmPackage.RISK_CATEGORY__HAS_RISKS);
}
return hasRisks;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case GenericbcmPackage.RISK_CATEGORY__SUB_CATEGORIES:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getSubCategories()).basicAdd(otherEnd, msgs);
case GenericbcmPackage.RISK_CATEGORY__PARENT_CATEGORY:
if (parentCategory != null)
msgs = ((InternalEObject)parentCategory).eInverseRemove(this, GenericbcmPackage.RISK_CATEGORY__SUB_CATEGORIES, RiskCategory.class, msgs);
return basicSetParentCategory((RiskCategory)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 GenericbcmPackage.RISK_CATEGORY__SUB_CATEGORIES:
return ((InternalEList<?>)getSubCategories()).basicRemove(otherEnd, msgs);
case GenericbcmPackage.RISK_CATEGORY__PARENT_CATEGORY:
return basicSetParentCategory(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 GenericbcmPackage.RISK_CATEGORY__SUB_CATEGORIES:
return getSubCategories();
case GenericbcmPackage.RISK_CATEGORY__PARENT_CATEGORY:
if (resolve) return getParentCategory();
return basicGetParentCategory();
case GenericbcmPackage.RISK_CATEGORY__HAS_RISKS:
return getHasRisks();
}
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 GenericbcmPackage.RISK_CATEGORY__SUB_CATEGORIES:
getSubCategories().clear();
getSubCategories().addAll((Collection<? extends RiskCategory>)newValue);
return;
case GenericbcmPackage.RISK_CATEGORY__PARENT_CATEGORY:
setParentCategory((RiskCategory)newValue);
return;
case GenericbcmPackage.RISK_CATEGORY__HAS_RISKS:
getHasRisks().clear();
getHasRisks().addAll((Collection<? extends FailureEffect>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case GenericbcmPackage.RISK_CATEGORY__SUB_CATEGORIES:
getSubCategories().clear();
return;
case GenericbcmPackage.RISK_CATEGORY__PARENT_CATEGORY:
setParentCategory((RiskCategory)null);
return;
case GenericbcmPackage.RISK_CATEGORY__HAS_RISKS:
getHasRisks().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case GenericbcmPackage.RISK_CATEGORY__SUB_CATEGORIES:
return subCategories != null && !subCategories.isEmpty();
case GenericbcmPackage.RISK_CATEGORY__PARENT_CATEGORY:
return parentCategory != null;
case GenericbcmPackage.RISK_CATEGORY__HAS_RISKS:
return hasRisks != null && !hasRisks.isEmpty();
}
return super.eIsSet(featureID);
}
} //RiskCategoryImpl