/** * Copyright (c) 2001-2011 Mad Cow Entertainment and 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: �bel Heged�s - initial API and implementation */ package madcow.magic.collection.impl; import madcow.magic.collection.CardInstance; import madcow.magic.collection.Collection; import madcow.magic.collection.CollectionPackage; import madcow.magic.collection.Container; import madcow.magic.database.card.Card; 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.util.EObjectContainmentWithInverseEList; import org.eclipse.emf.ecore.util.EObjectResolvingEList; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.InternalEList; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Container</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link madcow.magic.collection.impl.ContainerImpl#getCards <em>Cards</em>}</li> * <li>{@link madcow.magic.collection.impl.ContainerImpl#getPlace <em>Place</em>}</li> * <li>{@link madcow.magic.collection.impl.ContainerImpl#getCollection <em>Collection</em>}</li> * </ul> * </p> * * @generated */ public class ContainerImpl extends CollectionElementImpl implements Container { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static final String copyright = "Copyright (c) 2001-2011 Mad Cow Entertainment and Corporation\r\nAll rights reserved. This program and the accompanying materials\r\nare made available under the terms of the Eclipse Public License v1.0 \r\nwhich accompanies this distribution, and is available at\r\nhttp://www.eclipse.org/legal/epl-v10.html \r\n\r\nContributors: �bel Heged�s - initial API and implementation"; /** * The cached value of the '{@link #getCards() <em>Cards</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getCards() * @generated * @ordered */ protected EList<CardInstance> cards; /** * The default value of the '{@link #getPlace() <em>Place</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getPlace() * @generated * @ordered */ protected static final String PLACE_EDEFAULT = null; /** * The cached value of the '{@link #getPlace() <em>Place</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getPlace() * @generated * @ordered */ protected String place = PLACE_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ContainerImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return CollectionPackage.Literals.CONTAINER; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<CardInstance> getCards() { if (cards == null) { cards = new EObjectContainmentWithInverseEList<CardInstance>(CardInstance.class, this, CollectionPackage.CONTAINER__CARDS, CollectionPackage.CARD_INSTANCE__CONTAINER); } return cards; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getPlace() { return place; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setPlace(String newPlace) { String oldPlace = place; place = newPlace; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, CollectionPackage.CONTAINER__PLACE, oldPlace, place)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Collection getCollection() { if (eContainerFeatureID() != CollectionPackage.CONTAINER__COLLECTION) return null; return (Collection)eContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetCollection(Collection newCollection, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newCollection, CollectionPackage.CONTAINER__COLLECTION, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setCollection(Collection newCollection) { if (newCollection != eInternalContainer() || (eContainerFeatureID() != CollectionPackage.CONTAINER__COLLECTION && newCollection != null)) { if (EcoreUtil.isAncestor(this, newCollection)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newCollection != null) msgs = ((InternalEObject)newCollection).eInverseAdd(this, CollectionPackage.COLLECTION__CONTAINERS, Collection.class, msgs); msgs = basicSetCollection(newCollection, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, CollectionPackage.CONTAINER__COLLECTION, newCollection, newCollection)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case CollectionPackage.CONTAINER__CARDS: return ((InternalEList<InternalEObject>)(InternalEList<?>)getCards()).basicAdd(otherEnd, msgs); case CollectionPackage.CONTAINER__COLLECTION: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetCollection((Collection)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 CollectionPackage.CONTAINER__CARDS: return ((InternalEList<?>)getCards()).basicRemove(otherEnd, msgs); case CollectionPackage.CONTAINER__COLLECTION: return basicSetCollection(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case CollectionPackage.CONTAINER__COLLECTION: return eInternalContainer().eInverseRemove(this, CollectionPackage.COLLECTION__CONTAINERS, Collection.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 CollectionPackage.CONTAINER__CARDS: return getCards(); case CollectionPackage.CONTAINER__PLACE: return getPlace(); case CollectionPackage.CONTAINER__COLLECTION: return getCollection(); } 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 CollectionPackage.CONTAINER__CARDS: getCards().clear(); getCards().addAll((java.util.Collection<? extends CardInstance>)newValue); return; case CollectionPackage.CONTAINER__PLACE: setPlace((String)newValue); return; case CollectionPackage.CONTAINER__COLLECTION: setCollection((Collection)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case CollectionPackage.CONTAINER__CARDS: getCards().clear(); return; case CollectionPackage.CONTAINER__PLACE: setPlace(PLACE_EDEFAULT); return; case CollectionPackage.CONTAINER__COLLECTION: setCollection((Collection)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case CollectionPackage.CONTAINER__CARDS: return cards != null && !cards.isEmpty(); case CollectionPackage.CONTAINER__PLACE: return PLACE_EDEFAULT == null ? place != null : !PLACE_EDEFAULT.equals(place); case CollectionPackage.CONTAINER__COLLECTION: return getCollection() != 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(" (place: "); result.append(place); result.append(')'); return result.toString(); } } //ContainerImpl