/* * Copyright (c) 2005 Borland Software Corporation * * 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: * Dmitri Stadnik (Borland) - initial API and implementation */ package org.eclipse.gmf.examples.taipan.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.impl.EObjectImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.gmf.examples.taipan.Item; import org.eclipse.gmf.examples.taipan.Port; import org.eclipse.gmf.examples.taipan.Route; import org.eclipse.gmf.examples.taipan.Ship; import org.eclipse.gmf.examples.taipan.TaiPanPackage; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Ship</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.gmf.examples.taipan.impl.ShipImpl#getName <em>Name</em>}</li> * <li>{@link org.eclipse.gmf.examples.taipan.impl.ShipImpl#getDestination <em>Destination</em>}</li> * <li>{@link org.eclipse.gmf.examples.taipan.impl.ShipImpl#getRoute <em>Route</em>}</li> * <li>{@link org.eclipse.gmf.examples.taipan.impl.ShipImpl#getCargo <em>Cargo</em>}</li> * </ul> * </p> * * @generated */ public class ShipImpl extends EObjectImpl implements Ship { /** * 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 #getDestination() <em>Destination</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDestination() * @generated * @ordered */ protected Port destination; /** * The cached value of the '{@link #getRoute() <em>Route</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getRoute() * @generated * @ordered */ protected Route route; /** * The cached value of the '{@link #getCargo() <em>Cargo</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getCargo() * @generated * @ordered */ protected EList<Item> cargo; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ShipImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return TaiPanPackage.Literals.SHIP; } /** * <!-- 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, TaiPanPackage.SHIP__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Port getDestination() { if (destination != null && destination.eIsProxy()) { InternalEObject oldDestination = (InternalEObject) destination; destination = (Port) eResolveProxy(oldDestination); if (destination != oldDestination) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, TaiPanPackage.SHIP__DESTINATION, oldDestination, destination)); } } return destination; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Port basicGetDestination() { return destination; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setDestination(Port newDestination) { Port oldDestination = destination; destination = newDestination; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, TaiPanPackage.SHIP__DESTINATION, oldDestination, destination)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Route getRoute() { if (route != null && route.eIsProxy()) { InternalEObject oldRoute = (InternalEObject) route; route = (Route) eResolveProxy(oldRoute); if (route != oldRoute) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, TaiPanPackage.SHIP__ROUTE, oldRoute, route)); } } return route; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Route basicGetRoute() { return route; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setRoute(Route newRoute) { Route oldRoute = route; route = newRoute; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, TaiPanPackage.SHIP__ROUTE, oldRoute, route)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Item> getCargo() { if (cargo == null) { cargo = new EObjectContainmentEList<Item>(Item.class, this, TaiPanPackage.SHIP__CARGO); } return cargo; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case TaiPanPackage.SHIP__CARGO: return ((InternalEList<?>) getCargo()).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 TaiPanPackage.SHIP__NAME: return getName(); case TaiPanPackage.SHIP__DESTINATION: if (resolve) return getDestination(); return basicGetDestination(); case TaiPanPackage.SHIP__ROUTE: if (resolve) return getRoute(); return basicGetRoute(); case TaiPanPackage.SHIP__CARGO: return getCargo(); } 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 TaiPanPackage.SHIP__NAME: setName((String) newValue); return; case TaiPanPackage.SHIP__DESTINATION: setDestination((Port) newValue); return; case TaiPanPackage.SHIP__ROUTE: setRoute((Route) newValue); return; case TaiPanPackage.SHIP__CARGO: getCargo().clear(); getCargo().addAll((Collection<? extends Item>) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case TaiPanPackage.SHIP__NAME: setName(NAME_EDEFAULT); return; case TaiPanPackage.SHIP__DESTINATION: setDestination((Port) null); return; case TaiPanPackage.SHIP__ROUTE: setRoute((Route) null); return; case TaiPanPackage.SHIP__CARGO: getCargo().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case TaiPanPackage.SHIP__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case TaiPanPackage.SHIP__DESTINATION: return destination != null; case TaiPanPackage.SHIP__ROUTE: return route != null; case TaiPanPackage.SHIP__CARGO: return cargo != null && !cargo.isEmpty(); } 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: "); //$NON-NLS-1$ result.append(name); result.append(')'); return result.toString(); } } //ShipImpl