/**
* <copyright>
* Copyright (c) 2005 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
* </copyright>
*
* $Id: PickImpl.java,v 1.9 2011/03/30 18:54:24 rbrodt Exp $
*/
package org.eclipse.bpel.model.impl;
import java.util.Collection;
import org.eclipse.bpel.model.BPELPackage;
import org.eclipse.bpel.model.OnAlarm;
import org.eclipse.bpel.model.OnMessage;
import org.eclipse.bpel.model.Pick;
import org.eclipse.bpel.model.util.BPELConstants;
import org.eclipse.bpel.model.util.BPELUtils;
import org.eclipse.bpel.model.util.ReconciliationHelper;
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.EReference;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Pick</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.bpel.model.impl.PickImpl#getCreateInstance <em>Create Instance</em>}</li>
* <li>{@link org.eclipse.bpel.model.impl.PickImpl#getMessages <em>Messages</em>}</li>
* <li>{@link org.eclipse.bpel.model.impl.PickImpl#getAlarm <em>Alarm</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class PickImpl extends ActivityImpl implements Pick {
/**
* The default value of the '{@link #getCreateInstance() <em>Create Instance</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCreateInstance()
* @generated
* @ordered
*/
protected static final Boolean CREATE_INSTANCE_EDEFAULT = Boolean.FALSE;
/**
* The cached value of the '{@link #getCreateInstance() <em>Create Instance</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCreateInstance()
* @generated
* @ordered
*/
protected Boolean createInstance = CREATE_INSTANCE_EDEFAULT;
/**
* This is true if the Create Instance attribute has been set.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
protected boolean createInstanceESet;
/**
* 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<OnMessage> messages;
/**
* The cached value of the '{@link #getAlarm() <em>Alarm</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAlarm()
* @generated
* @ordered
*/
protected EList<OnAlarm> alarm;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected PickImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return BPELPackage.Literals.PICK;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Boolean getCreateInstance() {
return createInstance;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
public void setCreateInstance(Boolean newCreateInstance) {
Boolean oldCreateInstance = createInstance;
if (!isReconciling) {
ReconciliationHelper.replaceAttribute(this,
BPELConstants.AT_CREATE_INSTANCE,
BPELUtils.boolean2XML(newCreateInstance));
}
createInstance = newCreateInstance;
boolean oldCreateInstanceESet = createInstanceESet;
createInstanceESet = true;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
BPELPackage.PICK__CREATE_INSTANCE, oldCreateInstance,
createInstance, !oldCreateInstanceESet));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void unsetCreateInstance() {
Boolean oldCreateInstance = createInstance;
boolean oldCreateInstanceESet = createInstanceESet;
createInstance = CREATE_INSTANCE_EDEFAULT;
createInstanceESet = false;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.UNSET,
BPELPackage.PICK__CREATE_INSTANCE, oldCreateInstance,
CREATE_INSTANCE_EDEFAULT, oldCreateInstanceESet));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isSetCreateInstance() {
return createInstanceESet;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<OnMessage> getMessages() {
if (messages == null) {
messages = new EObjectContainmentEList<OnMessage>(OnMessage.class,
this, BPELPackage.PICK__MESSAGES);
}
return messages;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<OnAlarm> getAlarm() {
if (alarm == null) {
alarm = new EObjectContainmentEList<OnAlarm>(OnAlarm.class, this,
BPELPackage.PICK__ALARM);
}
return alarm;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case BPELPackage.PICK__MESSAGES:
return ((InternalEList<?>) getMessages()).basicRemove(otherEnd,
msgs);
case BPELPackage.PICK__ALARM:
return ((InternalEList<?>) getAlarm()).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 BPELPackage.PICK__CREATE_INSTANCE:
return getCreateInstance();
case BPELPackage.PICK__MESSAGES:
return getMessages();
case BPELPackage.PICK__ALARM:
return getAlarm();
}
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 BPELPackage.PICK__CREATE_INSTANCE:
setCreateInstance((Boolean) newValue);
return;
case BPELPackage.PICK__MESSAGES:
getMessages().clear();
getMessages().addAll((Collection<? extends OnMessage>) newValue);
return;
case BPELPackage.PICK__ALARM:
getAlarm().clear();
getAlarm().addAll((Collection<? extends OnAlarm>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case BPELPackage.PICK__CREATE_INSTANCE:
unsetCreateInstance();
return;
case BPELPackage.PICK__MESSAGES:
getMessages().clear();
return;
case BPELPackage.PICK__ALARM:
getAlarm().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case BPELPackage.PICK__CREATE_INSTANCE:
return isSetCreateInstance();
case BPELPackage.PICK__MESSAGES:
return messages != null && !messages.isEmpty();
case BPELPackage.PICK__ALARM:
return alarm != null && !alarm.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(" (createInstance: "); //$NON-NLS-1$
if (createInstanceESet)
result.append(createInstance);
else
result.append("<unset>"); //$NON-NLS-1$
result.append(')');
return result.toString();
}
@Override
protected void adoptContent(EReference reference, Object object) {
if (object instanceof OnMessage) {
ReconciliationHelper.adoptChild(this, messages, (OnMessage) object,
BPELConstants.ND_ON_MESSAGE);
}
if (object instanceof OnAlarm) {
ReconciliationHelper.adoptChild(this, alarm, (OnAlarm) object,
BPELConstants.ND_ON_ALARM);
}
super.adoptContent(reference, object);
}
@Override
protected void orphanContent(EReference reference, Object object) {
if (object instanceof OnMessage) {
ReconciliationHelper.orphanChild(this, (OnMessage) object);
}
if (object instanceof OnAlarm) {
ReconciliationHelper.orphanChild(this, (OnAlarm) object);
}
super.orphanContent(reference, object);
}
} //PickImpl