blob: b48f780afb67e3291c33179f3f7de1666c10f77d [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008 xored software, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Andrei Sobolev)
*******************************************************************************/
package org.eclipse.dltk.tcl.definitions.impl;
import java.util.Collection;
import org.eclipse.dltk.tcl.definitions.Argument;
import org.eclipse.dltk.tcl.definitions.ComplexArgument;
import org.eclipse.dltk.tcl.definitions.DefinitionsPackage;
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.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.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Complex Argument</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.dltk.tcl.definitions.impl.ComplexArgumentImpl#getLowerBound <em>Lower Bound</em>}</li>
* <li>{@link org.eclipse.dltk.tcl.definitions.impl.ComplexArgumentImpl#getUpperBound <em>Upper Bound</em>}</li>
* <li>{@link org.eclipse.dltk.tcl.definitions.impl.ComplexArgumentImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.dltk.tcl.definitions.impl.ComplexArgumentImpl#getArguments <em>Arguments</em>}</li>
* </ul>
*
* @generated
*/
public class ComplexArgumentImpl extends EObjectImpl implements ComplexArgument {
/**
* The default value of the '{@link #getLowerBound() <em>Lower Bound</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLowerBound()
* @generated
* @ordered
*/
protected static final int LOWER_BOUND_EDEFAULT = 1;
/**
* The cached value of the '{@link #getLowerBound() <em>Lower Bound</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLowerBound()
* @generated
* @ordered
*/
protected int lowerBound = LOWER_BOUND_EDEFAULT;
/**
* The default value of the '{@link #getUpperBound() <em>Upper Bound</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUpperBound()
* @generated
* @ordered
*/
protected static final int UPPER_BOUND_EDEFAULT = 1;
/**
* The cached value of the '{@link #getUpperBound() <em>Upper Bound</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUpperBound()
* @generated
* @ordered
*/
protected int upperBound = UPPER_BOUND_EDEFAULT;
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* The cached value of the '{@link #getArguments() <em>Arguments</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getArguments()
* @generated
* @ordered
*/
protected EList<Argument> arguments;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ComplexArgumentImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return DefinitionsPackage.Literals.COMPLEX_ARGUMENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getLowerBound() {
return lowerBound;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setLowerBound(int newLowerBound) {
int oldLowerBound = lowerBound;
lowerBound = newLowerBound;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.COMPLEX_ARGUMENT__LOWER_BOUND, oldLowerBound, lowerBound));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getUpperBound() {
return upperBound;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setUpperBound(int newUpperBound) {
int oldUpperBound = upperBound;
upperBound = newUpperBound;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.COMPLEX_ARGUMENT__UPPER_BOUND, oldUpperBound, upperBound));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getName() {
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setName(String newName) {
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.COMPLEX_ARGUMENT__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Argument> getArguments() {
if (arguments == null) {
arguments = new EObjectContainmentEList<Argument>(Argument.class, this, DefinitionsPackage.COMPLEX_ARGUMENT__ARGUMENTS);
}
return arguments;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case DefinitionsPackage.COMPLEX_ARGUMENT__ARGUMENTS:
return ((InternalEList<?>)getArguments()).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 DefinitionsPackage.COMPLEX_ARGUMENT__LOWER_BOUND:
return getLowerBound();
case DefinitionsPackage.COMPLEX_ARGUMENT__UPPER_BOUND:
return getUpperBound();
case DefinitionsPackage.COMPLEX_ARGUMENT__NAME:
return getName();
case DefinitionsPackage.COMPLEX_ARGUMENT__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 DefinitionsPackage.COMPLEX_ARGUMENT__LOWER_BOUND:
setLowerBound((Integer)newValue);
return;
case DefinitionsPackage.COMPLEX_ARGUMENT__UPPER_BOUND:
setUpperBound((Integer)newValue);
return;
case DefinitionsPackage.COMPLEX_ARGUMENT__NAME:
setName((String)newValue);
return;
case DefinitionsPackage.COMPLEX_ARGUMENT__ARGUMENTS:
getArguments().clear();
getArguments().addAll((Collection<? extends Argument>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case DefinitionsPackage.COMPLEX_ARGUMENT__LOWER_BOUND:
setLowerBound(LOWER_BOUND_EDEFAULT);
return;
case DefinitionsPackage.COMPLEX_ARGUMENT__UPPER_BOUND:
setUpperBound(UPPER_BOUND_EDEFAULT);
return;
case DefinitionsPackage.COMPLEX_ARGUMENT__NAME:
setName(NAME_EDEFAULT);
return;
case DefinitionsPackage.COMPLEX_ARGUMENT__ARGUMENTS:
getArguments().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case DefinitionsPackage.COMPLEX_ARGUMENT__LOWER_BOUND:
return lowerBound != LOWER_BOUND_EDEFAULT;
case DefinitionsPackage.COMPLEX_ARGUMENT__UPPER_BOUND:
return upperBound != UPPER_BOUND_EDEFAULT;
case DefinitionsPackage.COMPLEX_ARGUMENT__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case DefinitionsPackage.COMPLEX_ARGUMENT__ARGUMENTS:
return arguments != null && !arguments.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (lowerBound: ");
result.append(lowerBound);
result.append(", upperBound: ");
result.append(upperBound);
result.append(", name: ");
result.append(name);
result.append(')');
return result.toString();
}
} //ComplexArgumentImpl