/* | |
* 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.EObjectResolvingEList; | |
import org.eclipse.emf.ecore.util.InternalEList; | |
import org.eclipse.gmf.examples.taipan.Building; | |
import org.eclipse.gmf.examples.taipan.Port; | |
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>Port</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.gmf.examples.taipan.impl.PortImpl#getLocation <em>Location</em>}</li> | |
* <li>{@link org.eclipse.gmf.examples.taipan.impl.PortImpl#getBuildings <em>Buildings</em>}</li> | |
* <li>{@link org.eclipse.gmf.examples.taipan.impl.PortImpl#getRegister <em>Register</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class PortImpl extends EObjectImpl implements Port { | |
/** | |
* The default value of the '{@link #getLocation() <em>Location</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getLocation() | |
* @generated | |
* @ordered | |
*/ | |
protected static final String LOCATION_EDEFAULT = null; | |
/** | |
* The cached value of the '{@link #getLocation() <em>Location</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getLocation() | |
* @generated | |
* @ordered | |
*/ | |
protected String location = LOCATION_EDEFAULT; | |
/** | |
* The cached value of the '{@link #getBuildings() <em>Buildings</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getBuildings() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<Building> buildings; | |
/** | |
* The cached value of the '{@link #getRegister() <em>Register</em>}' reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getRegister() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<Ship> register; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected PortImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return TaiPanPackage.Literals.PORT; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public String getLocation() { | |
return location; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setLocation(String newLocation) { | |
String oldLocation = location; | |
location = newLocation; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, TaiPanPackage.PORT__LOCATION, oldLocation, location)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<Building> getBuildings() { | |
if (buildings == null) { | |
buildings = new EObjectContainmentEList<Building>(Building.class, this, TaiPanPackage.PORT__BUILDINGS); | |
} | |
return buildings; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<Ship> getRegister() { | |
if (register == null) { | |
register = new EObjectResolvingEList<Ship>(Ship.class, this, TaiPanPackage.PORT__REGISTER); | |
} | |
return register; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case TaiPanPackage.PORT__BUILDINGS: | |
return ((InternalEList<?>) getBuildings()).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.PORT__LOCATION: | |
return getLocation(); | |
case TaiPanPackage.PORT__BUILDINGS: | |
return getBuildings(); | |
case TaiPanPackage.PORT__REGISTER: | |
return getRegister(); | |
} | |
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.PORT__LOCATION: | |
setLocation((String) newValue); | |
return; | |
case TaiPanPackage.PORT__BUILDINGS: | |
getBuildings().clear(); | |
getBuildings().addAll((Collection<? extends Building>) newValue); | |
return; | |
case TaiPanPackage.PORT__REGISTER: | |
getRegister().clear(); | |
getRegister().addAll((Collection<? extends Ship>) newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case TaiPanPackage.PORT__LOCATION: | |
setLocation(LOCATION_EDEFAULT); | |
return; | |
case TaiPanPackage.PORT__BUILDINGS: | |
getBuildings().clear(); | |
return; | |
case TaiPanPackage.PORT__REGISTER: | |
getRegister().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case TaiPanPackage.PORT__LOCATION: | |
return LOCATION_EDEFAULT == null ? location != null : !LOCATION_EDEFAULT.equals(location); | |
case TaiPanPackage.PORT__BUILDINGS: | |
return buildings != null && !buildings.isEmpty(); | |
case TaiPanPackage.PORT__REGISTER: | |
return register != null && !register.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(" (location: "); //$NON-NLS-1$ | |
result.append(location); | |
result.append(')'); | |
return result.toString(); | |
} | |
} //PortImpl |