blob: b990a850e35cff0362d5805073d67a356a895f3e [file] [log] [blame]
/**
* <copyright>
* </copyright>
*
* $Id: ThreadImpl.java,v 1.1 2006/05/11 01:48:01 rgronback Exp $
*/
package org.eclipse.gmf.examples.mindmap.impl;
import java.util.Collection;
import java.util.Date;
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.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.gmf.examples.mindmap.MindmapPackage;
import org.eclipse.gmf.examples.mindmap.Resource;
import org.eclipse.gmf.examples.mindmap.ThreadItem;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Thread</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.gmf.examples.mindmap.impl.ThreadImpl#getAuthor <em>Author</em>}</li>
* <li>{@link org.eclipse.gmf.examples.mindmap.impl.ThreadImpl#getSubject <em>Subject</em>}</li>
* <li>{@link org.eclipse.gmf.examples.mindmap.impl.ThreadImpl#getItems <em>Items</em>}</li>
* <li>{@link org.eclipse.gmf.examples.mindmap.impl.ThreadImpl#getPostDate <em>Post Date</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ThreadImpl extends EObjectImpl implements org.eclipse.gmf.examples.mindmap.Thread {
/**
* The cached value of the '{@link #getAuthor() <em>Author</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAuthor()
* @generated
* @ordered
*/
protected Resource author = null;
/**
* The default value of the '{@link #getSubject() <em>Subject</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSubject()
* @generated
* @ordered
*/
protected static final String SUBJECT_EDEFAULT = null;
/**
* The cached value of the '{@link #getSubject() <em>Subject</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSubject()
* @generated
* @ordered
*/
protected String subject = SUBJECT_EDEFAULT;
/**
* The cached value of the '{@link #getItems() <em>Items</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getItems()
* @generated
* @ordered
*/
protected EList items = null;
/**
* The default value of the '{@link #getPostDate() <em>Post Date</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPostDate()
* @generated
* @ordered
*/
protected static final Date POST_DATE_EDEFAULT = null;
/**
* The cached value of the '{@link #getPostDate() <em>Post Date</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPostDate()
* @generated
* @ordered
*/
protected Date postDate = POST_DATE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ThreadImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return MindmapPackage.Literals.THREAD;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Resource getAuthor() {
if (author != null && author.eIsProxy()) {
InternalEObject oldAuthor = (InternalEObject)author;
author = (Resource)eResolveProxy(oldAuthor);
if (author != oldAuthor) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, MindmapPackage.THREAD__AUTHOR, oldAuthor, author));
}
}
return author;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Resource basicGetAuthor() {
return author;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetAuthor(Resource newAuthor, NotificationChain msgs) {
Resource oldAuthor = author;
author = newAuthor;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MindmapPackage.THREAD__AUTHOR, oldAuthor, newAuthor);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAuthor(Resource newAuthor) {
if (newAuthor != author) {
NotificationChain msgs = null;
if (author != null)
msgs = ((InternalEObject)author).eInverseRemove(this, MindmapPackage.RESOURCE__COMMENTS, Resource.class, msgs);
if (newAuthor != null)
msgs = ((InternalEObject)newAuthor).eInverseAdd(this, MindmapPackage.RESOURCE__COMMENTS, Resource.class, msgs);
msgs = basicSetAuthor(newAuthor, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MindmapPackage.THREAD__AUTHOR, newAuthor, newAuthor));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getSubject() {
return subject;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSubject(String newSubject) {
String oldSubject = subject;
subject = newSubject;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MindmapPackage.THREAD__SUBJECT, oldSubject, subject));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getItems() {
if (items == null) {
items = new EObjectContainmentEList(ThreadItem.class, this, MindmapPackage.THREAD__ITEMS);
}
return items;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Date getPostDate() {
return postDate;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setPostDate(Date newPostDate) {
Date oldPostDate = postDate;
postDate = newPostDate;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MindmapPackage.THREAD__POST_DATE, oldPostDate, postDate));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MindmapPackage.THREAD__AUTHOR:
if (author != null)
msgs = ((InternalEObject)author).eInverseRemove(this, MindmapPackage.RESOURCE__COMMENTS, Resource.class, msgs);
return basicSetAuthor((Resource)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MindmapPackage.THREAD__AUTHOR:
return basicSetAuthor(null, msgs);
case MindmapPackage.THREAD__ITEMS:
return ((InternalEList)getItems()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case MindmapPackage.THREAD__AUTHOR:
if (resolve) return getAuthor();
return basicGetAuthor();
case MindmapPackage.THREAD__SUBJECT:
return getSubject();
case MindmapPackage.THREAD__ITEMS:
return getItems();
case MindmapPackage.THREAD__POST_DATE:
return getPostDate();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case MindmapPackage.THREAD__AUTHOR:
setAuthor((Resource)newValue);
return;
case MindmapPackage.THREAD__SUBJECT:
setSubject((String)newValue);
return;
case MindmapPackage.THREAD__ITEMS:
getItems().clear();
getItems().addAll((Collection)newValue);
return;
case MindmapPackage.THREAD__POST_DATE:
setPostDate((Date)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(int featureID) {
switch (featureID) {
case MindmapPackage.THREAD__AUTHOR:
setAuthor((Resource)null);
return;
case MindmapPackage.THREAD__SUBJECT:
setSubject(SUBJECT_EDEFAULT);
return;
case MindmapPackage.THREAD__ITEMS:
getItems().clear();
return;
case MindmapPackage.THREAD__POST_DATE:
setPostDate(POST_DATE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
case MindmapPackage.THREAD__AUTHOR:
return author != null;
case MindmapPackage.THREAD__SUBJECT:
return SUBJECT_EDEFAULT == null ? subject != null : !SUBJECT_EDEFAULT.equals(subject);
case MindmapPackage.THREAD__ITEMS:
return items != null && !items.isEmpty();
case MindmapPackage.THREAD__POST_DATE:
return POST_DATE_EDEFAULT == null ? postDate != null : !POST_DATE_EDEFAULT.equals(postDate);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (subject: ");
result.append(subject);
result.append(", postDate: ");
result.append(postDate);
result.append(')');
return result.toString();
}
} //ThreadImpl