/** * <copyright> * </copyright> * * $Id$ */ package at.bestsolution.e4.addressbook.model.addressbook.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.ENotificationImpl; import org.eclipse.emf.ecore.impl.EObjectImpl; import org.eclipse.emf.ecore.util.EcoreUtil; import at.bestsolution.e4.addressbook.model.addressbook.AddressbookPackage; import at.bestsolution.e4.addressbook.model.addressbook.Country; import at.bestsolution.e4.addressbook.model.addressbook.FederalState; /** * <!-- begin-user-doc --> An implementation of the model object ' * <em><b>Federal State</b></em>'. <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li> * {@link at.bestsolution.e4.addressbook.model.addressbook.impl.FederalStateImpl#getName * <em>Name</em>}</li> * <li> * {@link at.bestsolution.e4.addressbook.model.addressbook.impl.FederalStateImpl#getCountry * <em>Country</em>}</li> * </ul> * </p> * * @generated */ public class FederalStateImpl extends EObjectImpl implements FederalState { /** * 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; /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ protected FederalStateImpl() { super(); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override protected EClass eStaticClass() { return AddressbookPackage.Literals.FEDERAL_STATE; } /** * <!-- 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, AddressbookPackage.FEDERAL_STATE__NAME, oldName, name)); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ public Country getCountry() { if (eContainerFeatureID() != AddressbookPackage.FEDERAL_STATE__COUNTRY) return null; return (Country) eContainer(); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ public NotificationChain basicSetCountry(Country newCountry, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject) newCountry, AddressbookPackage.FEDERAL_STATE__COUNTRY, msgs); return msgs; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ public void setCountry(Country newCountry) { if (newCountry != eInternalContainer() || (eContainerFeatureID() != AddressbookPackage.FEDERAL_STATE__COUNTRY && newCountry != null)) { if (EcoreUtil.isAncestor(this, newCountry)) throw new IllegalArgumentException( "Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newCountry != null) msgs = ((InternalEObject) newCountry).eInverseAdd(this, AddressbookPackage.COUNTRY__FEDERAL_STATES, Country.class, msgs); msgs = basicSetCountry(newCountry, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, AddressbookPackage.FEDERAL_STATE__COUNTRY, newCountry, newCountry)); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case AddressbookPackage.FEDERAL_STATE__COUNTRY: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetCountry((Country) 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 AddressbookPackage.FEDERAL_STATE__COUNTRY: return basicSetCountry(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature( NotificationChain msgs) { switch (eContainerFeatureID()) { case AddressbookPackage.FEDERAL_STATE__COUNTRY: return eInternalContainer().eInverseRemove(this, AddressbookPackage.COUNTRY__FEDERAL_STATES, Country.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 AddressbookPackage.FEDERAL_STATE__NAME: return getName(); case AddressbookPackage.FEDERAL_STATE__COUNTRY: return getCountry(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case AddressbookPackage.FEDERAL_STATE__NAME: setName((String) newValue); return; case AddressbookPackage.FEDERAL_STATE__COUNTRY: setCountry((Country) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case AddressbookPackage.FEDERAL_STATE__NAME: setName(NAME_EDEFAULT); return; case AddressbookPackage.FEDERAL_STATE__COUNTRY: setCountry((Country) null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case AddressbookPackage.FEDERAL_STATE__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT .equals(name); case AddressbookPackage.FEDERAL_STATE__COUNTRY: return getCountry() != 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(')'); return result.toString(); } } // FederalStateImpl