blob: 6203faaa07873881118af4c899f0086731a1af00 [file] [log] [blame]
/**
* Copyright (c) 2014 Fraunhofer FOKUS
* 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:
* Marc-Florian Wendland
*/
package org.eclipse.upr.soaml.impl;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
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.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.uml2.common.util.CacheAdapter;
import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.Signal;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.ValueSpecification;
import org.eclipse.upr.soaml.Milestone;
import org.eclipse.upr.soaml.SoaMLPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Milestone</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.upr.soaml.impl.MilestoneImpl#getProgress <em>Progress</em>}</li>
* <li>{@link org.eclipse.upr.soaml.impl.MilestoneImpl#getValues <em>Value</em>}</li>
* <li>{@link org.eclipse.upr.soaml.impl.MilestoneImpl#getSignal <em>Signal</em>}</li>
* <li>{@link org.eclipse.upr.soaml.impl.MilestoneImpl#getBase_Comment <em>Base Comment</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class MilestoneImpl extends EObjectImpl implements Milestone {
/**
* The default value of the '{@link #getProgress() <em>Progress</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getProgress()
* @generated
* @ordered
*/
protected static final int PROGRESS_EDEFAULT = 0;
/**
* The cached value of the '{@link #getProgress() <em>Progress</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getProgress()
* @generated
* @ordered
*/
protected int progress = PROGRESS_EDEFAULT;
/**
* The cached value of the '{@link #getValues() <em>Value</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getValues()
* @generated
* @ordered
*/
protected EList<ValueSpecification> values;
/**
* The cached value of the '{@link #getSignal() <em>Signal</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSignal()
* @generated
* @ordered
*/
protected Signal signal;
/**
* The cached value of the '{@link #getBase_Comment() <em>Base Comment</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBase_Comment()
* @generated
* @ordered
*/
protected Comment base_Comment;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MilestoneImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return SoaMLPackage.Literals.MILESTONE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getProgress() {
return progress;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setProgress(int newProgress) {
int oldProgress = progress;
progress = newProgress;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SoaMLPackage.MILESTONE__PROGRESS, oldProgress, progress));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<ValueSpecification> getValues() {
if (values == null) {
values = new EObjectResolvingEList<ValueSpecification>(ValueSpecification.class, this, SoaMLPackage.MILESTONE__VALUE);
}
return values;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ValueSpecification getValue(String name, Type type) {
return getValue(name, type, false, null);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ValueSpecification getValue(String name, Type type, boolean ignoreCase, EClass eClass) {
valueLoop: for (ValueSpecification value : getValues()) {
if (eClass != null && !eClass.isInstance(value))
continue valueLoop;
if (name != null && !(ignoreCase ? name.equalsIgnoreCase(value.getName()) : name.equals(value.getName())))
continue valueLoop;
if (type != null && !type.equals(value.getType()))
continue valueLoop;
return value;
}
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Signal getSignal() {
if (signal != null && signal.eIsProxy()) {
InternalEObject oldSignal = (InternalEObject)signal;
signal = (Signal)eResolveProxy(oldSignal);
if (signal != oldSignal) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, SoaMLPackage.MILESTONE__SIGNAL, oldSignal, signal));
}
}
return signal;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Signal basicGetSignal() {
return signal;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSignal(Signal newSignal) {
Signal oldSignal = signal;
signal = newSignal;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SoaMLPackage.MILESTONE__SIGNAL, oldSignal, signal));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Comment getBase_Comment() {
if (base_Comment != null && base_Comment.eIsProxy()) {
InternalEObject oldBase_Comment = (InternalEObject)base_Comment;
base_Comment = (Comment)eResolveProxy(oldBase_Comment);
if (base_Comment != oldBase_Comment) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, SoaMLPackage.MILESTONE__BASE_COMMENT, oldBase_Comment, base_Comment));
}
}
return base_Comment;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Comment basicGetBase_Comment() {
return base_Comment;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBase_Comment(Comment newBase_Comment) {
Comment oldBase_Comment = base_Comment;
base_Comment = newBase_Comment;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SoaMLPackage.MILESTONE__BASE_COMMENT, oldBase_Comment, base_Comment));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case SoaMLPackage.MILESTONE__PROGRESS:
return getProgress();
case SoaMLPackage.MILESTONE__VALUE:
return getValues();
case SoaMLPackage.MILESTONE__SIGNAL:
if (resolve) return getSignal();
return basicGetSignal();
case SoaMLPackage.MILESTONE__BASE_COMMENT:
if (resolve) return getBase_Comment();
return basicGetBase_Comment();
}
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 SoaMLPackage.MILESTONE__PROGRESS:
setProgress((Integer)newValue);
return;
case SoaMLPackage.MILESTONE__VALUE:
getValues().clear();
getValues().addAll((Collection<? extends ValueSpecification>)newValue);
return;
case SoaMLPackage.MILESTONE__SIGNAL:
setSignal((Signal)newValue);
return;
case SoaMLPackage.MILESTONE__BASE_COMMENT:
setBase_Comment((Comment)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case SoaMLPackage.MILESTONE__PROGRESS:
setProgress(PROGRESS_EDEFAULT);
return;
case SoaMLPackage.MILESTONE__VALUE:
getValues().clear();
return;
case SoaMLPackage.MILESTONE__SIGNAL:
setSignal((Signal)null);
return;
case SoaMLPackage.MILESTONE__BASE_COMMENT:
setBase_Comment((Comment)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case SoaMLPackage.MILESTONE__PROGRESS:
return progress != PROGRESS_EDEFAULT;
case SoaMLPackage.MILESTONE__VALUE:
return values != null && !values.isEmpty();
case SoaMLPackage.MILESTONE__SIGNAL:
return signal != null;
case SoaMLPackage.MILESTONE__BASE_COMMENT:
return base_Comment != 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(" (progress: ");
result.append(progress);
result.append(')');
return result.toString();
}
/**
* Creates a new instance of the specified Ecore class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param eClass The Ecore class of the instance to create.
* @return The new instance.
* @generated
*/
protected EObject create(EClass eClass) {
return EcoreUtil.create(eClass);
}
/**
* Retrieves the cache adapter for this '<em><b>Milestone</b></em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return The cache adapter for this '<em><b>Milestone</b></em>'.
* @generated
*/
protected CacheAdapter getCacheAdapter() {
return CacheAdapter.getCacheAdapter(this);
}
} //MilestoneImpl