blob: 41721280820e0f246b5264bf355aa0ba601ee20f [file] [log] [blame]
/**
* <copyright>
* </copyright>
*
* $Id: ClientImpl.java,v 1.3 2009/01/23 16:09:59 aboyko Exp $
*/
package org.eclipse.gmf.tests.runtime.emf.type.core.employee.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.EModelElementImpl;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.tests.runtime.emf.type.core.employee.Client;
import org.eclipse.gmf.tests.runtime.emf.type.core.employee.Customer;
import org.eclipse.gmf.tests.runtime.emf.type.core.employee.EmployeePackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Client</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.gmf.tests.runtime.emf.type.core.employee.impl.ClientImpl#getFirstName <em>First Name</em>}</li>
* <li>{@link org.eclipse.gmf.tests.runtime.emf.type.core.employee.impl.ClientImpl#getLastName <em>Last Name</em>}</li>
* <li>{@link org.eclipse.gmf.tests.runtime.emf.type.core.employee.impl.ClientImpl#getRepresents <em>Represents</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ClientImpl extends EModelElementImpl implements Client {
/**
* The default value of the '{@link #getFirstName() <em>First Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getFirstName()
* @generated
* @ordered
*/
protected static final String FIRST_NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getFirstName() <em>First Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getFirstName()
* @generated
* @ordered
*/
protected String firstName = FIRST_NAME_EDEFAULT;
/**
* The default value of the '{@link #getLastName() <em>Last Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLastName()
* @generated
* @ordered
*/
protected static final String LAST_NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getLastName() <em>Last Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLastName()
* @generated
* @ordered
*/
protected String lastName = LAST_NAME_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ClientImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return EmployeePackage.Literals.CLIENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getFirstName() {
return firstName;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setFirstName(String newFirstName) {
String oldFirstName = firstName;
firstName = newFirstName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EmployeePackage.CLIENT__FIRST_NAME, oldFirstName, firstName));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getLastName() {
return lastName;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setLastName(String newLastName) {
String oldLastName = lastName;
lastName = newLastName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EmployeePackage.CLIENT__LAST_NAME, oldLastName, lastName));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Customer getRepresents() {
if (eContainerFeatureID() != EmployeePackage.CLIENT__REPRESENTS) return null;
return (Customer)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetRepresents(Customer newRepresents, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newRepresents, EmployeePackage.CLIENT__REPRESENTS, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setRepresents(Customer newRepresents) {
if (newRepresents != eInternalContainer() || (eContainerFeatureID() != EmployeePackage.CLIENT__REPRESENTS && newRepresents != null)) {
if (EcoreUtil.isAncestor(this, newRepresents))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newRepresents != null)
msgs = ((InternalEObject)newRepresents).eInverseAdd(this, EmployeePackage.CUSTOMER__REPRESENTATIVES, Customer.class, msgs);
msgs = basicSetRepresents(newRepresents, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EmployeePackage.CLIENT__REPRESENTS, newRepresents, newRepresents));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case EmployeePackage.CLIENT__REPRESENTS:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetRepresents((Customer)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case EmployeePackage.CLIENT__REPRESENTS:
return basicSetRepresents(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case EmployeePackage.CLIENT__REPRESENTS:
return eInternalContainer().eInverseRemove(this, EmployeePackage.CUSTOMER__REPRESENTATIVES, Customer.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case EmployeePackage.CLIENT__FIRST_NAME:
return getFirstName();
case EmployeePackage.CLIENT__LAST_NAME:
return getLastName();
case EmployeePackage.CLIENT__REPRESENTS:
return getRepresents();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case EmployeePackage.CLIENT__FIRST_NAME:
setFirstName((String)newValue);
return;
case EmployeePackage.CLIENT__LAST_NAME:
setLastName((String)newValue);
return;
case EmployeePackage.CLIENT__REPRESENTS:
setRepresents((Customer)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(int featureID) {
switch (featureID) {
case EmployeePackage.CLIENT__FIRST_NAME:
setFirstName(FIRST_NAME_EDEFAULT);
return;
case EmployeePackage.CLIENT__LAST_NAME:
setLastName(LAST_NAME_EDEFAULT);
return;
case EmployeePackage.CLIENT__REPRESENTS:
setRepresents((Customer)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
case EmployeePackage.CLIENT__FIRST_NAME:
return FIRST_NAME_EDEFAULT == null ? firstName != null : !FIRST_NAME_EDEFAULT.equals(firstName);
case EmployeePackage.CLIENT__LAST_NAME:
return LAST_NAME_EDEFAULT == null ? lastName != null : !LAST_NAME_EDEFAULT.equals(lastName);
case EmployeePackage.CLIENT__REPRESENTS:
return getRepresents() != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (firstName: "); //$NON-NLS-1$
result.append(firstName);
result.append(", lastName: "); //$NON-NLS-1$
result.append(lastName);
result.append(')');
return result.toString();
}
} //ClientImpl