blob: a0e102bd0b5640570f820823f0dd7ad43096699f [file] [log] [blame]
/*
* 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 - initial API and implementation
*
* $Id: TimeEventImpl.java,v 1.1 2005/11/14 22:26:06 khussey Exp $
*/
package org.eclipse.uml2.uml.internal.impl;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.uml2.common.util.DerivedUnionEObjectEList;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.StringExpression;
import org.eclipse.uml2.uml.TemplateParameter;
import org.eclipse.uml2.uml.TimeEvent;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.ValueSpecification;
import org.eclipse.uml2.uml.VisibilityKind;
import org.eclipse.uml2.uml.internal.operations.TimeEventOperations;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Time Event</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.uml2.uml.internal.impl.TimeEventImpl#getOwnedElements <em>Owned Element</em>}</li>
* <li>{@link org.eclipse.uml2.uml.internal.impl.TimeEventImpl#isRelative <em>Is Relative</em>}</li>
* <li>{@link org.eclipse.uml2.uml.internal.impl.TimeEventImpl#getWhen <em>When</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class TimeEventImpl
extends EventImpl
implements TimeEvent {
/**
* The default value of the '{@link #isRelative() <em>Is Relative</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isRelative()
* @generated
* @ordered
*/
protected static final boolean IS_RELATIVE_EDEFAULT = false;
/**
* The flag representing the value of the '{@link #isRelative() <em>Is Relative</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isRelative()
* @generated
* @ordered
*/
protected static final int IS_RELATIVE_EFLAG = 1 << 8;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TimeEventImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return UMLPackage.eINSTANCE.getTimeEvent();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public List getOwnedElements() {
List ownedElement = (List) eVirtualGet(UMLPackage.TIME_EVENT__OWNED_ELEMENT);
if (ownedElement == null) {
eVirtualSet(UMLPackage.TIME_EVENT__OWNED_ELEMENT,
ownedElement = new DerivedUnionEObjectEList(Element.class,
this, UMLPackage.TIME_EVENT__OWNED_ELEMENT,
new EStructuralFeature[]{
UMLPackage.eINSTANCE.getElement_OwnedComment(),
UMLPackage.eINSTANCE.getNamedElement_NameExpression(),
UMLPackage.eINSTANCE.getTimeEvent_When()}));
}
return ownedElement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isRelative() {
return (eFlags & IS_RELATIVE_EFLAG) != 0;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setIsRelative(boolean newIsRelative) {
boolean oldIsRelative = (eFlags & IS_RELATIVE_EFLAG) != 0;
if (newIsRelative)
eFlags |= IS_RELATIVE_EFLAG;
else
eFlags &= ~IS_RELATIVE_EFLAG;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
UMLPackage.TIME_EVENT__IS_RELATIVE, oldIsRelative,
newIsRelative));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ValueSpecification getWhen() {
ValueSpecification when = (ValueSpecification) eVirtualGet(UMLPackage.TIME_EVENT__WHEN);
return when;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetWhen(ValueSpecification newWhen,
NotificationChain msgs) {
Object oldWhen = eVirtualSet(UMLPackage.TIME_EVENT__WHEN, newWhen);
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, UMLPackage.TIME_EVENT__WHEN,
oldWhen == EVIRTUAL_NO_VALUE
? null
: oldWhen, newWhen);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setWhen(ValueSpecification newWhen) {
ValueSpecification when = (ValueSpecification) eVirtualGet(UMLPackage.TIME_EVENT__WHEN);
if (newWhen != when) {
NotificationChain msgs = null;
if (when != null)
msgs = ((InternalEObject) when).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - UMLPackage.TIME_EVENT__WHEN, null,
msgs);
if (newWhen != null)
msgs = ((InternalEObject) newWhen).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - UMLPackage.TIME_EVENT__WHEN, null,
msgs);
msgs = basicSetWhen(newWhen, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
UMLPackage.TIME_EVENT__WHEN, newWhen, newWhen));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ValueSpecification createWhen(EClass eClass) {
ValueSpecification newWhen = (ValueSpecification) eClass.getEPackage()
.getEFactoryInstance().create(eClass);
setWhen(newWhen);
return newWhen;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean validateStartingTime(DiagnosticChain diagnostics, Map context) {
return TimeEventOperations.validateStartingTime(this, diagnostics,
context);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, Class baseClass, NotificationChain msgs) {
if (featureID >= 0) {
switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
case UMLPackage.TIME_EVENT__EANNOTATIONS :
return ((InternalEList) getEAnnotations()).basicRemove(
otherEnd, msgs);
case UMLPackage.TIME_EVENT__OWNED_COMMENT :
return ((InternalEList) getOwnedComments()).basicRemove(
otherEnd, msgs);
case UMLPackage.TIME_EVENT__CLIENT_DEPENDENCY :
return ((InternalEList) getClientDependencies())
.basicRemove(otherEnd, msgs);
case UMLPackage.TIME_EVENT__NAME_EXPRESSION :
return basicSetNameExpression(null, msgs);
case UMLPackage.TIME_EVENT__TEMPLATE_PARAMETER :
return basicSetTemplateParameter(null, msgs);
case UMLPackage.TIME_EVENT__OWNING_TEMPLATE_PARAMETER :
return eBasicSetContainer(null,
UMLPackage.TIME_EVENT__OWNING_TEMPLATE_PARAMETER, msgs);
case UMLPackage.TIME_EVENT__WHEN :
return basicSetWhen(null, msgs);
default :
return eDynamicInverseRemove(otherEnd, featureID,
baseClass, msgs);
}
}
return eBasicSetContainer(null, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(EStructuralFeature eFeature, boolean resolve) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UMLPackage.TIME_EVENT__EANNOTATIONS :
return getEAnnotations();
case UMLPackage.TIME_EVENT__OWNED_ELEMENT :
return getOwnedElements();
case UMLPackage.TIME_EVENT__OWNER :
if (resolve)
return getOwner();
return basicGetOwner();
case UMLPackage.TIME_EVENT__OWNED_COMMENT :
return getOwnedComments();
case UMLPackage.TIME_EVENT__NAME :
return getName();
case UMLPackage.TIME_EVENT__VISIBILITY :
return getVisibility();
case UMLPackage.TIME_EVENT__QUALIFIED_NAME :
return getQualifiedName();
case UMLPackage.TIME_EVENT__CLIENT_DEPENDENCY :
return getClientDependencies();
case UMLPackage.TIME_EVENT__NAMESPACE :
if (resolve)
return getNamespace();
return basicGetNamespace();
case UMLPackage.TIME_EVENT__NAME_EXPRESSION :
return getNameExpression();
case UMLPackage.TIME_EVENT__TEMPLATE_PARAMETER :
if (resolve)
return getTemplateParameter();
return basicGetTemplateParameter();
case UMLPackage.TIME_EVENT__OWNING_TEMPLATE_PARAMETER :
return getOwningTemplateParameter();
case UMLPackage.TIME_EVENT__IS_RELATIVE :
return isRelative()
? Boolean.TRUE
: Boolean.FALSE;
case UMLPackage.TIME_EVENT__WHEN :
return getWhen();
}
return eDynamicGet(eFeature, resolve);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(EStructuralFeature eFeature, Object newValue) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UMLPackage.TIME_EVENT__EANNOTATIONS :
getEAnnotations().clear();
getEAnnotations().addAll((Collection) newValue);
return;
case UMLPackage.TIME_EVENT__OWNED_COMMENT :
getOwnedComments().clear();
getOwnedComments().addAll((Collection) newValue);
return;
case UMLPackage.TIME_EVENT__NAME :
setName((String) newValue);
return;
case UMLPackage.TIME_EVENT__VISIBILITY :
setVisibility((VisibilityKind) newValue);
return;
case UMLPackage.TIME_EVENT__CLIENT_DEPENDENCY :
getClientDependencies().clear();
getClientDependencies().addAll((Collection) newValue);
return;
case UMLPackage.TIME_EVENT__NAME_EXPRESSION :
setNameExpression((StringExpression) newValue);
return;
case UMLPackage.TIME_EVENT__TEMPLATE_PARAMETER :
setTemplateParameter((TemplateParameter) newValue);
return;
case UMLPackage.TIME_EVENT__OWNING_TEMPLATE_PARAMETER :
setOwningTemplateParameter((TemplateParameter) newValue);
return;
case UMLPackage.TIME_EVENT__IS_RELATIVE :
setIsRelative(((Boolean) newValue).booleanValue());
return;
case UMLPackage.TIME_EVENT__WHEN :
setWhen((ValueSpecification) newValue);
return;
}
eDynamicSet(eFeature, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(EStructuralFeature eFeature) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UMLPackage.TIME_EVENT__EANNOTATIONS :
getEAnnotations().clear();
return;
case UMLPackage.TIME_EVENT__OWNED_COMMENT :
getOwnedComments().clear();
return;
case UMLPackage.TIME_EVENT__NAME :
setName(NAME_EDEFAULT);
return;
case UMLPackage.TIME_EVENT__VISIBILITY :
setVisibility(VISIBILITY_EDEFAULT);
return;
case UMLPackage.TIME_EVENT__CLIENT_DEPENDENCY :
getClientDependencies().clear();
return;
case UMLPackage.TIME_EVENT__NAME_EXPRESSION :
setNameExpression((StringExpression) null);
return;
case UMLPackage.TIME_EVENT__TEMPLATE_PARAMETER :
setTemplateParameter((TemplateParameter) null);
return;
case UMLPackage.TIME_EVENT__OWNING_TEMPLATE_PARAMETER :
setOwningTemplateParameter((TemplateParameter) null);
return;
case UMLPackage.TIME_EVENT__IS_RELATIVE :
setIsRelative(IS_RELATIVE_EDEFAULT);
return;
case UMLPackage.TIME_EVENT__WHEN :
setWhen((ValueSpecification) null);
return;
}
eDynamicUnset(eFeature);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(EStructuralFeature eFeature) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UMLPackage.TIME_EVENT__EANNOTATIONS :
return eAnnotations != null && !eAnnotations.isEmpty();
case UMLPackage.TIME_EVENT__OWNED_ELEMENT :
return isSetOwnedElements();
case UMLPackage.TIME_EVENT__OWNER :
return isSetOwner();
case UMLPackage.TIME_EVENT__OWNED_COMMENT :
List ownedComment = (List) eVirtualGet(UMLPackage.TIME_EVENT__OWNED_COMMENT);
return ownedComment != null && !ownedComment.isEmpty();
case UMLPackage.TIME_EVENT__NAME :
String name = eVirtualIsSet(UMLPackage.TIME_EVENT__NAME)
? (String) eVirtualGet(UMLPackage.TIME_EVENT__NAME)
: NAME_EDEFAULT;
return NAME_EDEFAULT == null
? name != null
: !NAME_EDEFAULT.equals(name);
case UMLPackage.TIME_EVENT__VISIBILITY :
return eVirtualIsSet(UMLPackage.TIME_EVENT__VISIBILITY)
&& eVirtualGet(UMLPackage.TIME_EVENT__VISIBILITY) != VISIBILITY_EDEFAULT;
case UMLPackage.TIME_EVENT__QUALIFIED_NAME :
return QUALIFIED_NAME_EDEFAULT == null
? getQualifiedName() != null
: !QUALIFIED_NAME_EDEFAULT.equals(getQualifiedName());
case UMLPackage.TIME_EVENT__CLIENT_DEPENDENCY :
List clientDependency = (List) eVirtualGet(UMLPackage.TIME_EVENT__CLIENT_DEPENDENCY);
return clientDependency != null && !clientDependency.isEmpty();
case UMLPackage.TIME_EVENT__NAMESPACE :
return isSetNamespace();
case UMLPackage.TIME_EVENT__NAME_EXPRESSION :
return eVirtualGet(UMLPackage.TIME_EVENT__NAME_EXPRESSION) != null;
case UMLPackage.TIME_EVENT__TEMPLATE_PARAMETER :
return eVirtualGet(UMLPackage.TIME_EVENT__TEMPLATE_PARAMETER) != null;
case UMLPackage.TIME_EVENT__OWNING_TEMPLATE_PARAMETER :
return getOwningTemplateParameter() != null;
case UMLPackage.TIME_EVENT__IS_RELATIVE :
return ((eFlags & IS_RELATIVE_EFLAG) != 0) != IS_RELATIVE_EDEFAULT;
case UMLPackage.TIME_EVENT__WHEN :
return eVirtualGet(UMLPackage.TIME_EVENT__WHEN) != null;
}
return eDynamicIsSet(eFeature);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String toString() {
if (eIsProxy())
return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (isRelative: "); //$NON-NLS-1$
result.append((eFlags & IS_RELATIVE_EFLAG) != 0);
result.append(')');
return result.toString();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isSetOwnedElements() {
return super.isSetOwnedElements()
|| eIsSet(UMLPackage.eINSTANCE.getTimeEvent_When());
}
} //TimeEventImpl