/**
*/
package at.bestsolution.emf.navi.tests.model.sample.impl;
import at.bestsolution.emf.navi.tests.model.sample.Group;
import at.bestsolution.emf.navi.tests.model.sample.Person;
import at.bestsolution.emf.navi.tests.model.sample.SamplePackage;
import java.util.Date;
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.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Person</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link at.bestsolution.emf.navi.tests.model.sample.impl.PersonImpl#getName <em>Name</em>}</li>
* <li>{@link at.bestsolution.emf.navi.tests.model.sample.impl.PersonImpl#getBirthdate <em>Birthdate</em>}</li>
* <li>{@link at.bestsolution.emf.navi.tests.model.sample.impl.PersonImpl#getGroup <em>Group</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class PersonImpl extends MinimalEObjectImpl.Container implements Person {
/**
* 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 default value of the '{@link #getBirthdate() <em>Birthdate</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBirthdate()
* @generated
* @ordered
*/
protected static final Date BIRTHDATE_EDEFAULT = null;
/**
* The cached value of the '{@link #getBirthdate() <em>Birthdate</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBirthdate()
* @generated
* @ordered
*/
protected Date birthdate = BIRTHDATE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected PersonImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return SamplePackage.Literals.PERSON;
}
/**
* <!-- 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, SamplePackage.PERSON__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Date getBirthdate() {
return birthdate;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBirthdate(Date newBirthdate) {
Date oldBirthdate = birthdate;
birthdate = newBirthdate;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SamplePackage.PERSON__BIRTHDATE, oldBirthdate, birthdate));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Group getGroup() {
if (eContainerFeatureID() != SamplePackage.PERSON__GROUP) return null;
return (Group)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetGroup(Group newGroup, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newGroup, SamplePackage.PERSON__GROUP, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setGroup(Group newGroup) {
if (newGroup != eInternalContainer() || (eContainerFeatureID() != SamplePackage.PERSON__GROUP && newGroup != null)) {
if (EcoreUtil.isAncestor(this, newGroup))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newGroup != null)
msgs = ((InternalEObject)newGroup).eInverseAdd(this, SamplePackage.GROUP__PERSONS, Group.class, msgs);
msgs = basicSetGroup(newGroup, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SamplePackage.PERSON__GROUP, newGroup, newGroup));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case SamplePackage.PERSON__GROUP:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetGroup((Group)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 SamplePackage.PERSON__GROUP:
return basicSetGroup(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case SamplePackage.PERSON__GROUP:
return eInternalContainer().eInverseRemove(this, SamplePackage.GROUP__PERSONS, Group.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case SamplePackage.PERSON__NAME:
return getName();
case SamplePackage.PERSON__BIRTHDATE:
return getBirthdate();
case SamplePackage.PERSON__GROUP:
return getGroup();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case SamplePackage.PERSON__NAME:
setName((String)newValue);
return;
case SamplePackage.PERSON__BIRTHDATE:
setBirthdate((Date)newValue);
return;
case SamplePackage.PERSON__GROUP:
setGroup((Group)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case SamplePackage.PERSON__NAME:
setName(NAME_EDEFAULT);
return;
case SamplePackage.PERSON__BIRTHDATE:
setBirthdate(BIRTHDATE_EDEFAULT);
return;
case SamplePackage.PERSON__GROUP:
setGroup((Group)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case SamplePackage.PERSON__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case SamplePackage.PERSON__BIRTHDATE:
return BIRTHDATE_EDEFAULT == null ? birthdate != null : !BIRTHDATE_EDEFAULT.equals(birthdate);
case SamplePackage.PERSON__GROUP:
return getGroup() != 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(", birthdate: ");
result.append(birthdate);
result.append(')');
return result.toString();
}
} //PersonImpl