/**
* <copyright>
* </copyright>
*
* $Id: MessageGroupImpl.java,v 1.2 2009/02/11 10:32:26 apanchenk Exp $
*/
package org.eclipse.dltk.tcl.tclchecker.model.messages.impl;
import java.util.Collection;
import org.eclipse.dltk.tcl.tclchecker.model.messages.CheckerMessage;
import org.eclipse.dltk.tcl.tclchecker.model.messages.MessageGroup;
import org.eclipse.dltk.tcl.tclchecker.model.messages.MessagesPackage;
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.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Message Group</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.dltk.tcl.tclchecker.model.messages.impl.MessageGroupImpl#getId <em>Id</em>}</li>
* <li>{@link org.eclipse.dltk.tcl.tclchecker.model.messages.impl.MessageGroupImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.dltk.tcl.tclchecker.model.messages.impl.MessageGroupImpl#getMessages <em>Messages</em>}</li>
* <li>{@link org.eclipse.dltk.tcl.tclchecker.model.messages.impl.MessageGroupImpl#getPriority <em>Priority</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class MessageGroupImpl extends EObjectImpl implements MessageGroup {
/**
* The default value of the '{@link #getId() <em>Id</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getId()
* @generated
* @ordered
*/
protected static final String ID_EDEFAULT = null;
/**
* The cached value of the '{@link #getId() <em>Id</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getId()
* @generated
* @ordered
*/
protected String id = ID_EDEFAULT;
/**
* 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;
/**
* The cached value of the '{@link #getMessages() <em>Messages</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMessages()
* @generated
* @ordered
*/
protected EList<CheckerMessage> messages;
/**
* The default value of the '{@link #getPriority() <em>Priority</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPriority()
* @generated
* @ordered
*/
protected static final int PRIORITY_EDEFAULT = 0;
/**
* The cached value of the '{@link #getPriority() <em>Priority</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPriority()
* @generated
* @ordered
*/
protected int priority = PRIORITY_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MessageGroupImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return MessagesPackage.Literals.MESSAGE_GROUP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getId() {
return id;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setId(String newId) {
String oldId = id;
id = newId;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MessagesPackage.MESSAGE_GROUP__ID, oldId, id));
}
/**
* <!-- 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, MessagesPackage.MESSAGE_GROUP__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<CheckerMessage> getMessages() {
if (messages == null) {
messages = new EObjectContainmentWithInverseEList<CheckerMessage>(CheckerMessage.class, this, MessagesPackage.MESSAGE_GROUP__MESSAGES, MessagesPackage.CHECKER_MESSAGE__GROUP);
}
return messages;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getPriority() {
return priority;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setPriority(int newPriority) {
int oldPriority = priority;
priority = newPriority;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MessagesPackage.MESSAGE_GROUP__PRIORITY, oldPriority, priority));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MessagesPackage.MESSAGE_GROUP__MESSAGES:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getMessages()).basicAdd(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 MessagesPackage.MESSAGE_GROUP__MESSAGES:
return ((InternalEList<?>)getMessages()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case MessagesPackage.MESSAGE_GROUP__ID:
return getId();
case MessagesPackage.MESSAGE_GROUP__NAME:
return getName();
case MessagesPackage.MESSAGE_GROUP__MESSAGES:
return getMessages();
case MessagesPackage.MESSAGE_GROUP__PRIORITY:
return new Integer(getPriority());
}
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 MessagesPackage.MESSAGE_GROUP__ID:
setId((String)newValue);
return;
case MessagesPackage.MESSAGE_GROUP__NAME:
setName((String)newValue);
return;
case MessagesPackage.MESSAGE_GROUP__MESSAGES:
getMessages().clear();
getMessages().addAll((Collection<? extends CheckerMessage>)newValue);
return;
case MessagesPackage.MESSAGE_GROUP__PRIORITY:
setPriority(((Integer)newValue).intValue());
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MessagesPackage.MESSAGE_GROUP__ID:
setId(ID_EDEFAULT);
return;
case MessagesPackage.MESSAGE_GROUP__NAME:
setName(NAME_EDEFAULT);
return;
case MessagesPackage.MESSAGE_GROUP__MESSAGES:
getMessages().clear();
return;
case MessagesPackage.MESSAGE_GROUP__PRIORITY:
setPriority(PRIORITY_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MessagesPackage.MESSAGE_GROUP__ID:
return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
case MessagesPackage.MESSAGE_GROUP__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case MessagesPackage.MESSAGE_GROUP__MESSAGES:
return messages != null && !messages.isEmpty();
case MessagesPackage.MESSAGE_GROUP__PRIORITY:
return priority != PRIORITY_EDEFAULT;
}
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(" (id: "); //$NON-NLS-1$
result.append(id);
result.append(", name: "); //$NON-NLS-1$
result.append(name);
result.append(", priority: "); //$NON-NLS-1$
result.append(priority);
result.append(')');
return result.toString();
}
} //MessageGroupImpl