/******************************************************************************* * Copyright (c) 2008 xored software, Inc. * * 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: * xored software, Inc. - initial API and Implementation (Andrei Sobolev) *******************************************************************************/ package org.eclipse.dltk.tcl.ast.impl; import java.util.Collection; import org.eclipse.dltk.tcl.ast.AstPackage; import org.eclipse.dltk.tcl.ast.Substitution; import org.eclipse.dltk.tcl.ast.TclCommand; import org.eclipse.dltk.tcl.parser.printer.SimpleCodePrinter; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; 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>Substitution</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.dltk.tcl.ast.impl.SubstitutionImpl#getCommands <em>Commands</em>}</li> * </ul> * </p> * * @generated */ public class SubstitutionImpl extends TclArgumentImpl implements Substitution { /** * The cached value of the '{@link #getCommands() <em>Commands</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getCommands() * @generated * @ordered */ protected EList<TclCommand> commands; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected SubstitutionImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return AstPackage.Literals.SUBSTITUTION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<TclCommand> getCommands() { if (commands == null) { commands = new EObjectContainmentEList<TclCommand>( TclCommand.class, this, AstPackage.SUBSTITUTION__COMMANDS); } return commands; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case AstPackage.SUBSTITUTION__COMMANDS: return ((InternalEList<?>) getCommands()).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 AstPackage.SUBSTITUTION__COMMANDS: return getCommands(); } 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 AstPackage.SUBSTITUTION__COMMANDS: getCommands().clear(); getCommands().addAll((Collection<? extends TclCommand>) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case AstPackage.SUBSTITUTION__COMMANDS: getCommands().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case AstPackage.SUBSTITUTION__COMMANDS: return commands != null && !commands.isEmpty(); } return super.eIsSet(featureID); } @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append("\n["); //$NON-NLS-1$ result.append(SimpleCodePrinter.getCommandsString(commands, false)); result.append("]"); //$NON-NLS-1$ return result.toString(); } } //SubstitutionImpl