| /** |
| */ |
| package graph.impl; |
| |
| import graph.Attribute; |
| import graph.Edge; |
| import graph.GraphPackage; |
| import graph.Node; |
| |
| import java.util.Arrays; |
| import java.util.Collection; |
| import java.util.List; |
| |
| 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.EObjectWithInverseResolvingEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Node</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link graph.impl.NodeImpl#getAttributes <em>Attributes</em>}</li> |
| * <li>{@link graph.impl.NodeImpl#getOutgoing <em>Outgoing</em>}</li> |
| * <li>{@link graph.impl.NodeImpl#getName <em>Name</em>}</li> |
| * <li>{@link graph.impl.NodeImpl#getIncoming <em>Incoming</em>}</li> |
| * <li>{@link graph.impl.NodeImpl#getType <em>Type</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class NodeImpl extends MinimalEObjectImpl.Container implements Node { |
| /** |
| * The cached value of the '{@link #getAttributes() <em>Attributes</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getAttributes() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Attribute> attributes; |
| |
| /** |
| * The cached value of the '{@link #getOutgoing() <em>Outgoing</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOutgoing() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Edge> outgoing; |
| |
| /** |
| * 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 #getIncoming() <em>Incoming</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIncoming() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Edge> incoming; |
| |
| /** |
| * The cached value of the '{@link #getType() <em>Type</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getType() |
| * @generated |
| * @ordered |
| */ |
| protected EClass type; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected NodeImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return GraphPackage.Literals.NODE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Attribute> getAttributes() { |
| if (attributes == null) { |
| attributes = new EObjectContainmentEList<Attribute>(Attribute.class, this, GraphPackage.NODE__ATTRIBUTES); |
| } |
| return attributes; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Edge> getOutgoing() { |
| if (outgoing == null) { |
| outgoing = new EObjectWithInverseResolvingEList<Edge>(Edge.class, this, GraphPackage.NODE__OUTGOING, GraphPackage.EDGE__SOURCE); |
| } |
| return outgoing; |
| } |
| |
| /** |
| * <!-- 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, GraphPackage.NODE__NAME, oldName, name)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Edge> getIncoming() { |
| if (incoming == null) { |
| incoming = new EObjectWithInverseResolvingEList<Edge>(Edge.class, this, GraphPackage.NODE__INCOMING, GraphPackage.EDGE__TARGET); |
| } |
| return incoming; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EClass getType() { |
| if (type != null && type.eIsProxy()) { |
| InternalEObject oldType = (InternalEObject)type; |
| type = (EClass)eResolveProxy(oldType); |
| if (type != oldType) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, GraphPackage.NODE__TYPE, oldType, type)); |
| } |
| } |
| return type; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EClass basicGetType() { |
| return type; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setType(EClass newType) { |
| EClass oldType = type; |
| type = newType; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, GraphPackage.NODE__TYPE, oldType, type)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case GraphPackage.NODE__OUTGOING: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getOutgoing()).basicAdd(otherEnd, msgs); |
| case GraphPackage.NODE__INCOMING: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getIncoming()).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 GraphPackage.NODE__ATTRIBUTES: |
| return ((InternalEList<?>)getAttributes()).basicRemove(otherEnd, msgs); |
| case GraphPackage.NODE__OUTGOING: |
| return ((InternalEList<?>)getOutgoing()).basicRemove(otherEnd, msgs); |
| case GraphPackage.NODE__INCOMING: |
| return ((InternalEList<?>)getIncoming()).basicRemove(otherEnd, 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 GraphPackage.NODE__ATTRIBUTES: |
| return getAttributes(); |
| case GraphPackage.NODE__OUTGOING: |
| return getOutgoing(); |
| case GraphPackage.NODE__NAME: |
| return getName(); |
| case GraphPackage.NODE__INCOMING: |
| return getIncoming(); |
| case GraphPackage.NODE__TYPE: |
| if (resolve) return getType(); |
| return basicGetType(); |
| } |
| 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 GraphPackage.NODE__ATTRIBUTES: |
| getAttributes().clear(); |
| getAttributes().addAll((Collection<? extends Attribute>)newValue); |
| return; |
| case GraphPackage.NODE__OUTGOING: |
| getOutgoing().clear(); |
| getOutgoing().addAll((Collection<? extends Edge>)newValue); |
| return; |
| case GraphPackage.NODE__NAME: |
| setName((String)newValue); |
| return; |
| case GraphPackage.NODE__INCOMING: |
| getIncoming().clear(); |
| getIncoming().addAll((Collection<? extends Edge>)newValue); |
| return; |
| case GraphPackage.NODE__TYPE: |
| setType((EClass)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case GraphPackage.NODE__ATTRIBUTES: |
| getAttributes().clear(); |
| return; |
| case GraphPackage.NODE__OUTGOING: |
| getOutgoing().clear(); |
| return; |
| case GraphPackage.NODE__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case GraphPackage.NODE__INCOMING: |
| getIncoming().clear(); |
| return; |
| case GraphPackage.NODE__TYPE: |
| setType((EClass)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case GraphPackage.NODE__ATTRIBUTES: |
| return attributes != null && !attributes.isEmpty(); |
| case GraphPackage.NODE__OUTGOING: |
| return outgoing != null && !outgoing.isEmpty(); |
| case GraphPackage.NODE__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case GraphPackage.NODE__INCOMING: |
| return incoming != null && !incoming.isEmpty(); |
| case GraphPackage.NODE__TYPE: |
| return type != 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(); |
| } |
| |
| public List<String> getNames() { |
| String[] names = name.split("="); |
| return Arrays.asList(names); |
| } |
| |
| public void removeName(String name) { |
| String[] names = this.name.split("="); |
| this.name = names[0]; |
| for (int i=1; i < names.length; i++) { |
| if (! names[i].equals(name)) { |
| this.name += "=" + names[i]; |
| } |
| } |
| } |
| |
| public void addNames(List<String> names) { |
| for (String str : names) { |
| if (! getNames().contains(str)) |
| this.name += "=" + str; |
| } |
| } |
| |
| } //NodeImpl |
| |