| /******************************************************************************* |
| * <copyright> |
| * |
| * Copyright (c) 2013, 2013 SAP AG. |
| * 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: |
| * SAP AG - initial API, implementation and documentation |
| * |
| * </copyright> |
| * |
| *******************************************************************************/ |
| package org.eclipse.fmc.mm.impl; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| import org.eclipse.emf.common.util.BasicEList; |
| 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.EObjectWithInverseResolvingEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.fmc.mm.Access; |
| import org.eclipse.fmc.mm.Agent; |
| import org.eclipse.fmc.mm.Channel; |
| import org.eclipse.fmc.mm.FMCConnection; |
| import org.eclipse.fmc.mm.FmcPackage; |
| import org.eclipse.fmc.mm.IFMCElementVisitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Agent</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.fmc.mm.impl.AgentImpl#getAccessConnections <em>Access Connections</em>}</li> |
| * <li>{@link org.eclipse.fmc.mm.impl.AgentImpl#isHuman <em>Human</em>}</li> |
| * <li>{@link org.eclipse.fmc.mm.impl.AgentImpl#getSourceChannels <em>Source Channels</em>}</li> |
| * <li>{@link org.eclipse.fmc.mm.impl.AgentImpl#getTargetChannels <em>Target Channels</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class AgentImpl extends FMCNodeImpl implements Agent { |
| /** |
| * The cached value of the '{@link #getAccessConnections() <em>Access Connections</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getAccessConnections() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Access> accessConnections; |
| |
| /** |
| * The default value of the '{@link #isHuman() <em>Human</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isHuman() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean HUMAN_EDEFAULT = false; |
| |
| /** |
| * The cached value of the '{@link #isHuman() <em>Human</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isHuman() |
| * @generated |
| * @ordered |
| */ |
| protected boolean human = HUMAN_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getSourceChannels() <em>Source Channels</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getSourceChannels() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Channel> sourceChannels; |
| |
| /** |
| * The cached value of the '{@link #getTargetChannels() <em>Target Channels</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTargetChannels() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Channel> targetChannels; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected AgentImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return FmcPackage.Literals.AGENT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Access> getAccessConnections() { |
| if (accessConnections == null) { |
| accessConnections = new EObjectWithInverseResolvingEList<Access>(Access.class, this, FmcPackage.AGENT__ACCESS_CONNECTIONS, FmcPackage.ACCESS__AGENT); |
| } |
| return accessConnections; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isHuman() { |
| return human; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setHuman(boolean newHuman) { |
| boolean oldHuman = human; |
| human = newHuman; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, FmcPackage.AGENT__HUMAN, oldHuman, human)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Channel> getSourceChannels() { |
| if (sourceChannels == null) { |
| sourceChannels = new EObjectWithInverseResolvingEList<Channel>(Channel.class, this, FmcPackage.AGENT__SOURCE_CHANNELS, FmcPackage.CHANNEL__SOURCE); |
| } |
| return sourceChannels; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Channel> getTargetChannels() { |
| if (targetChannels == null) { |
| targetChannels = new EObjectWithInverseResolvingEList<Channel>(Channel.class, this, FmcPackage.AGENT__TARGET_CHANNELS, FmcPackage.CHANNEL__TARGET); |
| } |
| return targetChannels; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case FmcPackage.AGENT__ACCESS_CONNECTIONS: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getAccessConnections()).basicAdd(otherEnd, msgs); |
| case FmcPackage.AGENT__SOURCE_CHANNELS: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getSourceChannels()).basicAdd(otherEnd, msgs); |
| case FmcPackage.AGENT__TARGET_CHANNELS: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getTargetChannels()).basicAdd(otherEnd, msgs); |
| } |
| return super.eInverseAdd(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case FmcPackage.AGENT__ACCESS_CONNECTIONS: |
| return ((InternalEList<?>)getAccessConnections()).basicRemove(otherEnd, msgs); |
| case FmcPackage.AGENT__SOURCE_CHANNELS: |
| return ((InternalEList<?>)getSourceChannels()).basicRemove(otherEnd, msgs); |
| case FmcPackage.AGENT__TARGET_CHANNELS: |
| return ((InternalEList<?>)getTargetChannels()).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 FmcPackage.AGENT__ACCESS_CONNECTIONS: |
| return getAccessConnections(); |
| case FmcPackage.AGENT__HUMAN: |
| return isHuman(); |
| case FmcPackage.AGENT__SOURCE_CHANNELS: |
| return getSourceChannels(); |
| case FmcPackage.AGENT__TARGET_CHANNELS: |
| return getTargetChannels(); |
| } |
| 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 FmcPackage.AGENT__ACCESS_CONNECTIONS: |
| getAccessConnections().clear(); |
| getAccessConnections().addAll((Collection<? extends Access>)newValue); |
| return; |
| case FmcPackage.AGENT__HUMAN: |
| setHuman((Boolean)newValue); |
| return; |
| case FmcPackage.AGENT__SOURCE_CHANNELS: |
| getSourceChannels().clear(); |
| getSourceChannels().addAll((Collection<? extends Channel>)newValue); |
| return; |
| case FmcPackage.AGENT__TARGET_CHANNELS: |
| getTargetChannels().clear(); |
| getTargetChannels().addAll((Collection<? extends Channel>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case FmcPackage.AGENT__ACCESS_CONNECTIONS: |
| getAccessConnections().clear(); |
| return; |
| case FmcPackage.AGENT__HUMAN: |
| setHuman(HUMAN_EDEFAULT); |
| return; |
| case FmcPackage.AGENT__SOURCE_CHANNELS: |
| getSourceChannels().clear(); |
| return; |
| case FmcPackage.AGENT__TARGET_CHANNELS: |
| getTargetChannels().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case FmcPackage.AGENT__ACCESS_CONNECTIONS: |
| return accessConnections != null && !accessConnections.isEmpty(); |
| case FmcPackage.AGENT__HUMAN: |
| return human != HUMAN_EDEFAULT; |
| case FmcPackage.AGENT__SOURCE_CHANNELS: |
| return sourceChannels != null && !sourceChannels.isEmpty(); |
| case FmcPackage.AGENT__TARGET_CHANNELS: |
| return targetChannels != null && !targetChannels.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(" (human: "); |
| result.append(human); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| @Override |
| public Object accept(IFMCElementVisitor visitor, Object object) { |
| return visitor.visitAgent(this, object); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| public EList<FMCConnection> getAllConnections() { |
| EList<FMCConnection> allConnections = new BasicEList<FMCConnection>(); |
| allConnections.addAll(getSourceChannels()); |
| allConnections.addAll(getTargetChannels()); |
| allConnections.addAll(getAccessConnections()); |
| return allConnections; |
| } |
| |
| } //AgentImpl |