/*******************************************************************************
* Copyright (c) 2011-2013 University of Mannheim: Chair for Software Engineering
* 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:
* Ralph Gerbig - initial API and implementation and initial documentation
*******************************************************************************/
package de.uni_mannheim.informatik.swt.models.plm.PLM.impl;
import de.uni_mannheim.informatik.swt.models.plm.PLM.Domain;
import de.uni_mannheim.informatik.swt.models.plm.PLM.Element;
import de.uni_mannheim.informatik.swt.models.plm.PLM.PLMPackage;
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.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Domain</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link de.uni_mannheim.informatik.swt.models.plm.PLM.impl.DomainImpl#getName <em>Name</em>}</li>
* <li>{@link de.uni_mannheim.informatik.swt.models.plm.PLM.impl.DomainImpl#getOntologies <em>Ontologies</em>}</li>
* <li>{@link de.uni_mannheim.informatik.swt.models.plm.PLM.impl.DomainImpl#getDomains <em>Domains</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class DomainImpl extends MinimalEObjectImpl.Container implements Domain {
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* The cached value of the '{@link #getOntologies() <em>Ontologies</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOntologies()
* @generated
* @ordered
*/
protected EList<Element> ontologies;
/**
* The cached value of the '{@link #getDomains() <em>Domains</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDomains()
* @generated
* @ordered
*/
protected Domain domains;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected DomainImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return PLMPackage.Literals.DOMAIN;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getName() {
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setName(String newName) {
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, PLMPackage.DOMAIN__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Element> getOntologies() {
if (ontologies == null) {
ontologies = new EObjectContainmentEList<Element>(Element.class, this, PLMPackage.DOMAIN__ONTOLOGIES);
}
return ontologies;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Domain getDomains() {
return domains;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetDomains(Domain newDomains, NotificationChain msgs) {
Domain oldDomains = domains;
domains = newDomains;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PLMPackage.DOMAIN__DOMAINS, oldDomains, newDomains);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setDomains(Domain newDomains) {
if (newDomains != domains) {
NotificationChain msgs = null;
if (domains != null)
msgs = ((InternalEObject)domains).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PLMPackage.DOMAIN__DOMAINS, null, msgs);
if (newDomains != null)
msgs = ((InternalEObject)newDomains).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PLMPackage.DOMAIN__DOMAINS, null, msgs);
msgs = basicSetDomains(newDomains, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, PLMPackage.DOMAIN__DOMAINS, newDomains, newDomains));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case PLMPackage.DOMAIN__ONTOLOGIES:
return ((InternalEList<?>)getOntologies()).basicRemove(otherEnd, msgs);
case PLMPackage.DOMAIN__DOMAINS:
return basicSetDomains(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 PLMPackage.DOMAIN__NAME:
return getName();
case PLMPackage.DOMAIN__ONTOLOGIES:
return getOntologies();
case PLMPackage.DOMAIN__DOMAINS:
return getDomains();
}
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 PLMPackage.DOMAIN__NAME:
setName((String)newValue);
return;
case PLMPackage.DOMAIN__ONTOLOGIES:
getOntologies().clear();
getOntologies().addAll((Collection<? extends Element>)newValue);
return;
case PLMPackage.DOMAIN__DOMAINS:
setDomains((Domain)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case PLMPackage.DOMAIN__NAME:
setName(NAME_EDEFAULT);
return;
case PLMPackage.DOMAIN__ONTOLOGIES:
getOntologies().clear();
return;
case PLMPackage.DOMAIN__DOMAINS:
setDomains((Domain)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case PLMPackage.DOMAIN__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case PLMPackage.DOMAIN__ONTOLOGIES:
return ontologies != null && !ontologies.isEmpty();
case PLMPackage.DOMAIN__DOMAINS:
return domains != 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(" (name: ");
result.append(name);
result.append(')');
return result.toString();
}
} //DomainImpl