/******************************************************************************* * Copyright (c) 2011-2013 University of Mannheim: Chair for Software Engineering * 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: * Ralph Gerbig - initial API and implementation and initial documentation *******************************************************************************/ package de.uni_mannheim.informatik.swt.models.plm.PLM.impl; import de.uni_mannheim.informatik.swt.models.plm.PLM.Feature; import de.uni_mannheim.informatik.swt.models.plm.PLM.Method; import de.uni_mannheim.informatik.swt.models.plm.PLM.PLMPackage; import de.uni_mannheim.informatik.swt.models.plm.PLM.Parameter; import java.lang.reflect.InvocationTargetException; import java.util.Collection; 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.common.util.WrappedException; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EOperation; 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>Method</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link de.uni_mannheim.informatik.swt.models.plm.PLM.impl.MethodImpl#getBody <em>Body</em>}</li> * <li>{@link de.uni_mannheim.informatik.swt.models.plm.PLM.impl.MethodImpl#getInput <em>Input</em>}</li> * <li>{@link de.uni_mannheim.informatik.swt.models.plm.PLM.impl.MethodImpl#getOutput <em>Output</em>}</li> * </ul> * </p> * * @generated */ public class MethodImpl extends FeatureImpl implements Method { /** * The default value of the '{@link #getBody() <em>Body</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getBody() * @generated * @ordered */ protected static final String BODY_EDEFAULT = null; /** * The cached value of the '{@link #getBody() <em>Body</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getBody() * @generated * @ordered */ protected String body = BODY_EDEFAULT; /** * The cached value of the '{@link #getInput() <em>Input</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getInput() * @generated * @ordered */ protected EList<Parameter> input; /** * The cached value of the '{@link #getOutput() <em>Output</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOutput() * @generated * @ordered */ protected EList<Parameter> output; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected MethodImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return PLMPackage.Literals.METHOD; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getBody() { return body; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setBody(String newBody) { String oldBody = body; body = newBody; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, PLMPackage.METHOD__BODY, oldBody, body)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Parameter> getInput() { if (input == null) { input = new EObjectContainmentEList<Parameter>(Parameter.class, this, PLMPackage.METHOD__INPUT); } return input; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Parameter> getOutput() { if (output == null) { output = new EObjectContainmentEList<Parameter>(Parameter.class, this, PLMPackage.METHOD__OUTPUT); } return output; } /** * The cached invocation delegate for the '{@link #represent() <em>Represent</em>}' operation. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #represent() * @generated * @ordered */ protected static final EOperation.Internal.InvocationDelegate REPRESENT__EINVOCATION_DELEGATE = ((EOperation.Internal)PLMPackage.Literals.METHOD___REPRESENT).getInvocationDelegate(); /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String represent() { try { return (String)REPRESENT__EINVOCATION_DELEGATE.dynamicInvoke(this, null); } catch (InvocationTargetException ite) { throw new WrappedException(ite); } } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case PLMPackage.METHOD__INPUT: return ((InternalEList<?>)getInput()).basicRemove(otherEnd, msgs); case PLMPackage.METHOD__OUTPUT: return ((InternalEList<?>)getOutput()).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 PLMPackage.METHOD__BODY: return getBody(); case PLMPackage.METHOD__INPUT: return getInput(); case PLMPackage.METHOD__OUTPUT: return getOutput(); } 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 PLMPackage.METHOD__BODY: setBody((String)newValue); return; case PLMPackage.METHOD__INPUT: getInput().clear(); getInput().addAll((Collection<? extends Parameter>)newValue); return; case PLMPackage.METHOD__OUTPUT: getOutput().clear(); getOutput().addAll((Collection<? extends Parameter>)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case PLMPackage.METHOD__BODY: setBody(BODY_EDEFAULT); return; case PLMPackage.METHOD__INPUT: getInput().clear(); return; case PLMPackage.METHOD__OUTPUT: getOutput().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case PLMPackage.METHOD__BODY: return BODY_EDEFAULT == null ? body != null : !BODY_EDEFAULT.equals(body); case PLMPackage.METHOD__INPUT: return input != null && !input.isEmpty(); case PLMPackage.METHOD__OUTPUT: return output != null && !output.isEmpty(); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public int eDerivedOperationID(int baseOperationID, Class<?> baseClass) { if (baseClass == Feature.class) { switch (baseOperationID) { case PLMPackage.FEATURE___REPRESENT: return PLMPackage.METHOD___REPRESENT; default: return super.eDerivedOperationID(baseOperationID, baseClass); } } return super.eDerivedOperationID(baseOperationID, baseClass); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case PLMPackage.METHOD___REPRESENT: return represent(); } return super.eInvoke(operationID, arguments); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (body: "); result.append(body); result.append(')'); return result.toString(); } } //MethodImpl