/*******************************************************************************
* 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.ArgumentMatch;
import org.eclipse.dltk.tcl.ast.AstPackage;
import org.eclipse.dltk.tcl.ast.TclArgument;
import org.eclipse.dltk.tcl.definitions.Argument;
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.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Argument Match</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.dltk.tcl.ast.impl.ArgumentMatchImpl#getDefinition <em>Definition</em>}</li>
* <li>{@link org.eclipse.dltk.tcl.ast.impl.ArgumentMatchImpl#getArguments <em>Arguments</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ArgumentMatchImpl extends EObjectImpl implements ArgumentMatch {
/**
* The cached value of the '{@link #getDefinition() <em>Definition</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDefinition()
* @generated
* @ordered
*/
protected Argument definition;
/**
* The cached value of the '{@link #getArguments() <em>Arguments</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getArguments()
* @generated
* @ordered
*/
protected EList<TclArgument> arguments;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ArgumentMatchImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return AstPackage.Literals.ARGUMENT_MATCH;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Argument getDefinition() {
if (definition != null && definition.eIsProxy()) {
InternalEObject oldDefinition = (InternalEObject) definition;
definition = (Argument) eResolveProxy(oldDefinition);
if (definition != oldDefinition) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE,
AstPackage.ARGUMENT_MATCH__DEFINITION,
oldDefinition, definition));
}
}
return definition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Argument basicGetDefinition() {
return definition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setDefinition(Argument newDefinition) {
Argument oldDefinition = definition;
definition = newDefinition;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
AstPackage.ARGUMENT_MATCH__DEFINITION, oldDefinition,
definition));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<TclArgument> getArguments() {
if (arguments == null) {
arguments = new EObjectResolvingEList<TclArgument>(
TclArgument.class, this,
AstPackage.ARGUMENT_MATCH__ARGUMENTS);
}
return arguments;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case AstPackage.ARGUMENT_MATCH__DEFINITION:
if (resolve)
return getDefinition();
return basicGetDefinition();
case AstPackage.ARGUMENT_MATCH__ARGUMENTS:
return getArguments();
}
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.ARGUMENT_MATCH__DEFINITION:
setDefinition((Argument) newValue);
return;
case AstPackage.ARGUMENT_MATCH__ARGUMENTS:
getArguments().clear();
getArguments().addAll((Collection<? extends TclArgument>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case AstPackage.ARGUMENT_MATCH__DEFINITION:
setDefinition((Argument) null);
return;
case AstPackage.ARGUMENT_MATCH__ARGUMENTS:
getArguments().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case AstPackage.ARGUMENT_MATCH__DEFINITION:
return definition != null;
case AstPackage.ARGUMENT_MATCH__ARGUMENTS:
return arguments != null && !arguments.isEmpty();
}
return super.eIsSet(featureID);
}
} //ArgumentMatchImpl