blob: 5af3d568592896b3f482dfd19502fd5caddc0dda [file] [log] [blame]
package org.eclipse.stem.core.graph.impl;
/*******************************************************************************
* Copyright (c) 2011 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.emf.common.notify.Notification;
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.EObjectImpl;
import org.eclipse.stem.core.graph.Exchange;
import org.eclipse.stem.core.graph.ExchangeType;
import org.eclipse.stem.core.graph.GraphPackage;
import org.eclipse.stem.core.graph.Label;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Exchange</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.stem.core.graph.impl.ExchangeImpl#getOtherLabel <em>Other Label</em>}</li>
* <li>{@link org.eclipse.stem.core.graph.impl.ExchangeImpl#getCount <em>Count</em>}</li>
* <li>{@link org.eclipse.stem.core.graph.impl.ExchangeImpl#getType <em>Type</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ExchangeImpl extends EObjectImpl implements Exchange {
/**
* The cached value of the '{@link #getOtherLabel() <em>Other Label</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOtherLabel()
* @generated
* @ordered
*/
protected Label otherLabel;
/**
* The default value of the '{@link #getCount() <em>Count</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCount()
* @generated
* @ordered
*/
protected static final double COUNT_EDEFAULT = 0.0;
/**
* The cached value of the '{@link #getCount() <em>Count</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCount()
* @generated
* @ordered
*/
protected double count = COUNT_EDEFAULT;
/**
* The default value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected static final ExchangeType TYPE_EDEFAULT = ExchangeType.BIRTHS_AND_DEATHS;
/**
* The cached value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected ExchangeType type = TYPE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ExchangeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return GraphPackage.Literals.EXCHANGE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Label getOtherLabel() {
if (otherLabel != null && otherLabel.eIsProxy()) {
InternalEObject oldOtherLabel = (InternalEObject)otherLabel;
otherLabel = (Label)eResolveProxy(oldOtherLabel);
if (otherLabel != oldOtherLabel) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, GraphPackage.EXCHANGE__OTHER_LABEL, oldOtherLabel, otherLabel));
}
}
return otherLabel;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Label basicGetOtherLabel() {
return otherLabel;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOtherLabel(Label newOtherLabel) {
Label oldOtherLabel = otherLabel;
otherLabel = newOtherLabel;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GraphPackage.EXCHANGE__OTHER_LABEL, oldOtherLabel, otherLabel));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public double getCount() {
return count;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCount(double newCount) {
double oldCount = count;
count = newCount;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GraphPackage.EXCHANGE__COUNT, oldCount, count));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ExchangeType getType() {
return type;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setType(ExchangeType newType) {
ExchangeType oldType = type;
type = newType == null ? TYPE_EDEFAULT : newType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GraphPackage.EXCHANGE__TYPE, oldType, type));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case GraphPackage.EXCHANGE__OTHER_LABEL:
if (resolve) return getOtherLabel();
return basicGetOtherLabel();
case GraphPackage.EXCHANGE__COUNT:
return getCount();
case GraphPackage.EXCHANGE__TYPE:
return getType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case GraphPackage.EXCHANGE__OTHER_LABEL:
setOtherLabel((Label)newValue);
return;
case GraphPackage.EXCHANGE__COUNT:
setCount((Double)newValue);
return;
case GraphPackage.EXCHANGE__TYPE:
setType((ExchangeType)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case GraphPackage.EXCHANGE__OTHER_LABEL:
setOtherLabel((Label)null);
return;
case GraphPackage.EXCHANGE__COUNT:
setCount(COUNT_EDEFAULT);
return;
case GraphPackage.EXCHANGE__TYPE:
setType(TYPE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case GraphPackage.EXCHANGE__OTHER_LABEL:
return otherLabel != null;
case GraphPackage.EXCHANGE__COUNT:
return count != COUNT_EDEFAULT;
case GraphPackage.EXCHANGE__TYPE:
return type != TYPE_EDEFAULT;
}
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(" (count: "); //$NON-NLS-1$
result.append(count);
result.append(", type: "); //$NON-NLS-1$
result.append(type);
result.append(')');
return result.toString();
}
public int compareTo(Exchange o) {
String thisIdentifier;
String otherIdentifier;
if (getType() == ExchangeType.BIRTHS_AND_DEATHS) {
thisIdentifier = getType().getName();
} else {
thisIdentifier = getType().getName() + "," + getOtherLabel().getURI();
}
if (o.getType() == ExchangeType.BIRTHS_AND_DEATHS) {
otherIdentifier = o.getType().getName();
} else {
otherIdentifier = o.getType().getName() + "," + o.getOtherLabel().getURI();
}
return thisIdentifier.compareTo(otherIdentifier);
}
} //ExchangeImpl