/**
*/
package fr.inria.atlanmod.collaboro.history.impl;
import fr.inria.atlanmod.collaboro.history.Collaboration;
import fr.inria.atlanmod.collaboro.history.Comment;
import fr.inria.atlanmod.collaboro.history.HistoryPackage;
import fr.inria.atlanmod.collaboro.history.User;
import fr.inria.atlanmod.collaboro.history.Vote;
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.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Vote</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link fr.inria.atlanmod.collaboro.history.impl.VoteImpl#isAgreement <em>Agreement</em>}</li>
* <li>{@link fr.inria.atlanmod.collaboro.history.impl.VoteImpl#getUser <em>User</em>}</li>
* <li>{@link fr.inria.atlanmod.collaboro.history.impl.VoteImpl#getComment <em>Comment</em>}</li>
* <li>{@link fr.inria.atlanmod.collaboro.history.impl.VoteImpl#getCollaboration <em>Collaboration</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class VoteImpl extends EObjectImpl implements Vote {
/**
* The default value of the '{@link #isAgreement() <em>Agreement</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isAgreement()
* @generated
* @ordered
*/
protected static final boolean AGREEMENT_EDEFAULT = false;
/**
* The cached value of the '{@link #isAgreement() <em>Agreement</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isAgreement()
* @generated
* @ordered
*/
protected boolean agreement = AGREEMENT_EDEFAULT;
/**
* The cached value of the '{@link #getUser() <em>User</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUser()
* @generated
* @ordered
*/
protected User user;
/**
* The cached value of the '{@link #getComment() <em>Comment</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getComment()
* @generated
* @ordered
*/
protected Comment comment;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected VoteImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return HistoryPackage.Literals.VOTE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isAgreement() {
return agreement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAgreement(boolean newAgreement) {
boolean oldAgreement = agreement;
agreement = newAgreement;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, HistoryPackage.VOTE__AGREEMENT, oldAgreement, agreement));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public User getUser() {
if (user != null && user.eIsProxy()) {
InternalEObject oldUser = (InternalEObject)user;
user = (User)eResolveProxy(oldUser);
if (user != oldUser) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, HistoryPackage.VOTE__USER, oldUser, user));
}
}
return user;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public User basicGetUser() {
return user;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetUser(User newUser, NotificationChain msgs) {
User oldUser = user;
user = newUser;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, HistoryPackage.VOTE__USER, oldUser, newUser);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setUser(User newUser) {
if (newUser != user) {
NotificationChain msgs = null;
if (user != null)
msgs = ((InternalEObject)user).eInverseRemove(this, HistoryPackage.USER__VOTES, User.class, msgs);
if (newUser != null)
msgs = ((InternalEObject)newUser).eInverseAdd(this, HistoryPackage.USER__VOTES, User.class, msgs);
msgs = basicSetUser(newUser, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, HistoryPackage.VOTE__USER, newUser, newUser));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Comment getComment() {
if (comment != null && comment.eIsProxy()) {
InternalEObject oldComment = (InternalEObject)comment;
comment = (Comment)eResolveProxy(oldComment);
if (comment != oldComment) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, HistoryPackage.VOTE__COMMENT, oldComment, comment));
}
}
return comment;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Comment basicGetComment() {
return comment;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setComment(Comment newComment) {
Comment oldComment = comment;
comment = newComment;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, HistoryPackage.VOTE__COMMENT, oldComment, comment));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Collaboration getCollaboration() {
if (eContainerFeatureID() != HistoryPackage.VOTE__COLLABORATION) return null;
return (Collaboration)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCollaboration(Collaboration newCollaboration, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newCollaboration, HistoryPackage.VOTE__COLLABORATION, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCollaboration(Collaboration newCollaboration) {
if (newCollaboration != eInternalContainer() || (eContainerFeatureID() != HistoryPackage.VOTE__COLLABORATION && newCollaboration != null)) {
if (EcoreUtil.isAncestor(this, newCollaboration))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newCollaboration != null)
msgs = ((InternalEObject)newCollaboration).eInverseAdd(this, HistoryPackage.COLLABORATION__VOTES, Collaboration.class, msgs);
msgs = basicSetCollaboration(newCollaboration, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, HistoryPackage.VOTE__COLLABORATION, newCollaboration, newCollaboration));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case HistoryPackage.VOTE__USER:
if (user != null)
msgs = ((InternalEObject)user).eInverseRemove(this, HistoryPackage.USER__VOTES, User.class, msgs);
return basicSetUser((User)otherEnd, msgs);
case HistoryPackage.VOTE__COLLABORATION:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetCollaboration((Collaboration)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 HistoryPackage.VOTE__USER:
return basicSetUser(null, msgs);
case HistoryPackage.VOTE__COLLABORATION:
return basicSetCollaboration(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case HistoryPackage.VOTE__COLLABORATION:
return eInternalContainer().eInverseRemove(this, HistoryPackage.COLLABORATION__VOTES, Collaboration.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 HistoryPackage.VOTE__AGREEMENT:
return isAgreement();
case HistoryPackage.VOTE__USER:
if (resolve) return getUser();
return basicGetUser();
case HistoryPackage.VOTE__COMMENT:
if (resolve) return getComment();
return basicGetComment();
case HistoryPackage.VOTE__COLLABORATION:
return getCollaboration();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case HistoryPackage.VOTE__AGREEMENT:
setAgreement((Boolean)newValue);
return;
case HistoryPackage.VOTE__USER:
setUser((User)newValue);
return;
case HistoryPackage.VOTE__COMMENT:
setComment((Comment)newValue);
return;
case HistoryPackage.VOTE__COLLABORATION:
setCollaboration((Collaboration)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case HistoryPackage.VOTE__AGREEMENT:
setAgreement(AGREEMENT_EDEFAULT);
return;
case HistoryPackage.VOTE__USER:
setUser((User)null);
return;
case HistoryPackage.VOTE__COMMENT:
setComment((Comment)null);
return;
case HistoryPackage.VOTE__COLLABORATION:
setCollaboration((Collaboration)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case HistoryPackage.VOTE__AGREEMENT:
return agreement != AGREEMENT_EDEFAULT;
case HistoryPackage.VOTE__USER:
return user != null;
case HistoryPackage.VOTE__COMMENT:
return comment != null;
case HistoryPackage.VOTE__COLLABORATION:
return getCollaboration() != 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(" (agreement: ");
result.append(agreement);
result.append(')');
return result.toString();
}
} //VoteImpl