blob: 30a12ff29c8354432bc14081808c2303e7c3f9ea [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2011 - 2014 University of Padova, Intecs
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
*
*****************************************************************************/
package org.polarsys.chess.chessmlprofile.Dependability.StateBased.MaintenanceMonitoring.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.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.uml2.uml.Activity;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Type;
import org.polarsys.chess.chessmlprofile.Dependability.StateBased.MaintenanceMonitoring.MaintenanceMonitoringPackage;
import org.polarsys.chess.chessmlprofile.Dependability.StateBased.MaintenanceMonitoring.Replace;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Replace</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.polarsys.chess.chessmlprofile.Dependability.StateBased.MaintenanceMonitoring.impl.ReplaceImpl#getTargets <em>Targets</em>}</li>
* <li>{@link org.polarsys.chess.chessmlprofile.Dependability.StateBased.MaintenanceMonitoring.impl.ReplaceImpl#getReplacement <em>Replacement</em>}</li>
* </ul>
*
* @generated
*/
public class ReplaceImpl extends MMActivitiesImpl implements Replace {
/**
* The cached value of the '{@link #getTargets() <em>Targets</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTargets()
* @generated
* @ordered
*/
protected EList<Property> targets;
/**
* The cached value of the '{@link #getReplacement() <em>Replacement</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getReplacement()
* @generated
* @ordered
*/
protected Activity replacement;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ReplaceImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return MaintenanceMonitoringPackage.Literals.REPLACE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Property> getTargets() {
if (targets == null) {
targets = new EObjectResolvingEList<Property>(Property.class, this, MaintenanceMonitoringPackage.REPLACE__TARGETS);
}
return targets;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Property getTargets(String name, Type type) {
return getTargets(name, type, false, null);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Property getTargets(String name, Type type, boolean ignoreCase, EClass eClass) {
targetsLoop: for (Property targets : getTargets()) {
if (eClass != null && !eClass.isInstance(targets))
continue targetsLoop;
if (name != null && !(ignoreCase ? name.equalsIgnoreCase(targets.getName()) : name.equals(targets.getName())))
continue targetsLoop;
if (type != null && !type.equals(targets.getType()))
continue targetsLoop;
return targets;
}
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Activity getReplacement() {
if (replacement != null && replacement.eIsProxy()) {
InternalEObject oldReplacement = (InternalEObject)replacement;
replacement = (Activity)eResolveProxy(oldReplacement);
if (replacement != oldReplacement) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, MaintenanceMonitoringPackage.REPLACE__REPLACEMENT, oldReplacement, replacement));
}
}
return replacement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Activity basicGetReplacement() {
return replacement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setReplacement(Activity newReplacement) {
Activity oldReplacement = replacement;
replacement = newReplacement;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MaintenanceMonitoringPackage.REPLACE__REPLACEMENT, oldReplacement, replacement));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case MaintenanceMonitoringPackage.REPLACE__TARGETS:
return getTargets();
case MaintenanceMonitoringPackage.REPLACE__REPLACEMENT:
if (resolve) return getReplacement();
return basicGetReplacement();
}
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 MaintenanceMonitoringPackage.REPLACE__TARGETS:
getTargets().clear();
getTargets().addAll((Collection<? extends Property>)newValue);
return;
case MaintenanceMonitoringPackage.REPLACE__REPLACEMENT:
setReplacement((Activity)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MaintenanceMonitoringPackage.REPLACE__TARGETS:
getTargets().clear();
return;
case MaintenanceMonitoringPackage.REPLACE__REPLACEMENT:
setReplacement((Activity)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MaintenanceMonitoringPackage.REPLACE__TARGETS:
return targets != null && !targets.isEmpty();
case MaintenanceMonitoringPackage.REPLACE__REPLACEMENT:
return replacement != null;
}
return super.eIsSet(featureID);
}
} //ReplaceImpl