/**
* <copyright>
* </copyright>
*
* $Id$
*/
package com.emf4sw.owl.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.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import com.emf4sw.owl.ClassExpression;
import com.emf4sw.owl.OWLPackage;
import com.emf4sw.owl.ObjectUnionOf;
import com.emf4sw.rdf.BlankNode;
import com.emf4sw.rdf.RDFGraph;
import com.emf4sw.rdf.RDFPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Object Union Of</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link com.emf4sw.owl.impl.ObjectUnionOfImpl#getNodeID <em>Node ID</em>}</li>
* <li>{@link com.emf4sw.owl.impl.ObjectUnionOfImpl#getGraph <em>Graph</em>}</li>
* <li>{@link com.emf4sw.owl.impl.ObjectUnionOfImpl#getUnionOf <em>Union Of</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ObjectUnionOfImpl extends ClassExpressionImpl implements ObjectUnionOf {
/**
* The default value of the '{@link #getNodeID() <em>Node ID</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getNodeID()
* @generated
* @ordered
*/
protected static final String NODE_ID_EDEFAULT = null;
/**
* The cached value of the '{@link #getNodeID() <em>Node ID</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getNodeID()
* @generated
* @ordered
*/
protected String nodeID = NODE_ID_EDEFAULT;
/**
* The cached value of the '{@link #getUnionOf() <em>Union Of</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUnionOf()
* @generated
* @ordered
*/
protected EList<ClassExpression> unionOf;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ObjectUnionOfImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return OWLPackage.Literals.OBJECT_UNION_OF;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getNodeID() {
return nodeID;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setNodeID(String newNodeID) {
String oldNodeID = nodeID;
nodeID = newNodeID;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, OWLPackage.OBJECT_UNION_OF__NODE_ID, oldNodeID, nodeID));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public RDFGraph getGraph() {
if (eContainerFeatureID() != OWLPackage.OBJECT_UNION_OF__GRAPH) return null;
return (RDFGraph)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetGraph(RDFGraph newGraph, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newGraph, OWLPackage.OBJECT_UNION_OF__GRAPH, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setGraph(RDFGraph newGraph) {
if (newGraph != eInternalContainer() || (eContainerFeatureID() != OWLPackage.OBJECT_UNION_OF__GRAPH && newGraph != null)) {
if (EcoreUtil.isAncestor(this, newGraph))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newGraph != null)
msgs = ((InternalEObject)newGraph).eInverseAdd(this, RDFPackage.RDF_GRAPH__BLANK_NODES, RDFGraph.class, msgs);
msgs = basicSetGraph(newGraph, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, OWLPackage.OBJECT_UNION_OF__GRAPH, newGraph, newGraph));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<ClassExpression> getUnionOf() {
if (unionOf == null) {
unionOf = new EObjectResolvingEList<ClassExpression>(ClassExpression.class, this, OWLPackage.OBJECT_UNION_OF__UNION_OF);
}
return unionOf;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case OWLPackage.OBJECT_UNION_OF__GRAPH:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetGraph((RDFGraph)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 OWLPackage.OBJECT_UNION_OF__GRAPH:
return basicSetGraph(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case OWLPackage.OBJECT_UNION_OF__GRAPH:
return eInternalContainer().eInverseRemove(this, RDFPackage.RDF_GRAPH__BLANK_NODES, RDFGraph.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 OWLPackage.OBJECT_UNION_OF__NODE_ID:
return getNodeID();
case OWLPackage.OBJECT_UNION_OF__GRAPH:
return getGraph();
case OWLPackage.OBJECT_UNION_OF__UNION_OF:
return getUnionOf();
}
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 OWLPackage.OBJECT_UNION_OF__NODE_ID:
setNodeID((String)newValue);
return;
case OWLPackage.OBJECT_UNION_OF__GRAPH:
setGraph((RDFGraph)newValue);
return;
case OWLPackage.OBJECT_UNION_OF__UNION_OF:
getUnionOf().clear();
getUnionOf().addAll((Collection<? extends ClassExpression>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case OWLPackage.OBJECT_UNION_OF__NODE_ID:
setNodeID(NODE_ID_EDEFAULT);
return;
case OWLPackage.OBJECT_UNION_OF__GRAPH:
setGraph((RDFGraph)null);
return;
case OWLPackage.OBJECT_UNION_OF__UNION_OF:
getUnionOf().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case OWLPackage.OBJECT_UNION_OF__NODE_ID:
return NODE_ID_EDEFAULT == null ? nodeID != null : !NODE_ID_EDEFAULT.equals(nodeID);
case OWLPackage.OBJECT_UNION_OF__GRAPH:
return getGraph() != null;
case OWLPackage.OBJECT_UNION_OF__UNION_OF:
return unionOf != null && !unionOf.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == BlankNode.class) {
switch (derivedFeatureID) {
case OWLPackage.OBJECT_UNION_OF__NODE_ID: return RDFPackage.BLANK_NODE__NODE_ID;
case OWLPackage.OBJECT_UNION_OF__GRAPH: return RDFPackage.BLANK_NODE__GRAPH;
default: return -1;
}
}
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
if (baseClass == BlankNode.class) {
switch (baseFeatureID) {
case RDFPackage.BLANK_NODE__NODE_ID: return OWLPackage.OBJECT_UNION_OF__NODE_ID;
case RDFPackage.BLANK_NODE__GRAPH: return OWLPackage.OBJECT_UNION_OF__GRAPH;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (nodeID: ");
result.append(nodeID);
result.append(')');
return result.toString();
}
} //ObjectUnionOfImpl