blob: 5914335123e205dd598f349e7e74987c5bf26669 [file] [log] [blame]
/**
* Copyright (c) 2008-2011 Chair for Applied Software Engineering,
* Technische Universitaet Muenchen.
* 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:
*/
package org.eclipse.emf.emfstore.bowling.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.EDataTypeEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.emfstore.bowling.BowlingPackage;
import org.eclipse.emf.emfstore.bowling.Game;
import org.eclipse.emf.emfstore.bowling.Matchup;
import org.eclipse.emf.emfstore.bowling.Player;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Game</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.emf.emfstore.bowling.impl.GameImpl#getMatchup <em>Matchup</em>}</li>
* <li>{@link org.eclipse.emf.emfstore.bowling.impl.GameImpl#getPlayer <em>Player</em>}</li>
* <li>{@link org.eclipse.emf.emfstore.bowling.impl.GameImpl#getFrames <em>Frames</em>}</li>
* </ul>
*
* @generated
*/
public class GameImpl extends EObjectImpl implements Game {
/**
* The cached value of the '{@link #getPlayer() <em>Player</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getPlayer()
* @generated
* @ordered
*/
protected Player player;
/**
* The cached value of the '{@link #getFrames() <em>Frames</em>}' attribute list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getFrames()
* @generated
* @ordered
*/
protected EList<Integer> frames;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected GameImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return BowlingPackage.Literals.GAME;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public Matchup getMatchup() {
if (eContainerFeatureID() != BowlingPackage.GAME__MATCHUP)
return null;
return (Matchup) eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public Matchup basicGetMatchup() {
if (eContainerFeatureID() != BowlingPackage.GAME__MATCHUP)
return null;
return (Matchup) eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetMatchup(Matchup newMatchup, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject) newMatchup, BowlingPackage.GAME__MATCHUP, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public void setMatchup(Matchup newMatchup) {
if (newMatchup != eInternalContainer()
|| (eContainerFeatureID() != BowlingPackage.GAME__MATCHUP && newMatchup != null)) {
if (EcoreUtil.isAncestor(this, newMatchup))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newMatchup != null)
msgs = ((InternalEObject) newMatchup).eInverseAdd(this, BowlingPackage.MATCHUP__GAMES, Matchup.class,
msgs);
msgs = basicSetMatchup(newMatchup, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(
new ENotificationImpl(this, Notification.SET, BowlingPackage.GAME__MATCHUP, newMatchup, newMatchup));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public Player getPlayer() {
if (player != null && player.eIsProxy()) {
InternalEObject oldPlayer = (InternalEObject) player;
player = (Player) eResolveProxy(oldPlayer);
if (player != oldPlayer) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, BowlingPackage.GAME__PLAYER, oldPlayer,
player));
}
}
return player;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public Player basicGetPlayer() {
return player;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public void setPlayer(Player newPlayer) {
Player oldPlayer = player;
player = newPlayer;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BowlingPackage.GAME__PLAYER, oldPlayer, player));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public EList<Integer> getFrames() {
if (frames == null) {
frames = new EDataTypeEList<Integer>(Integer.class, this, BowlingPackage.GAME__FRAMES);
}
return frames;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case BowlingPackage.GAME__MATCHUP:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetMatchup((Matchup) 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 BowlingPackage.GAME__MATCHUP:
return basicSetMatchup(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case BowlingPackage.GAME__MATCHUP:
return eInternalContainer().eInverseRemove(this, BowlingPackage.MATCHUP__GAMES, Matchup.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 BowlingPackage.GAME__MATCHUP:
if (resolve)
return getMatchup();
return basicGetMatchup();
case BowlingPackage.GAME__PLAYER:
if (resolve)
return getPlayer();
return basicGetPlayer();
case BowlingPackage.GAME__FRAMES:
return getFrames();
}
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 BowlingPackage.GAME__MATCHUP:
setMatchup((Matchup) newValue);
return;
case BowlingPackage.GAME__PLAYER:
setPlayer((Player) newValue);
return;
case BowlingPackage.GAME__FRAMES:
getFrames().clear();
getFrames().addAll((Collection<? extends Integer>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case BowlingPackage.GAME__MATCHUP:
setMatchup((Matchup) null);
return;
case BowlingPackage.GAME__PLAYER:
setPlayer((Player) null);
return;
case BowlingPackage.GAME__FRAMES:
getFrames().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case BowlingPackage.GAME__MATCHUP:
return basicGetMatchup() != null;
case BowlingPackage.GAME__PLAYER:
return player != null;
case BowlingPackage.GAME__FRAMES:
return frames != null && !frames.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(" (frames: "); //$NON-NLS-1$
result.append(frames);
result.append(')');
return result.toString();
}
} // GameImpl