blob: ea29b1c035096b7c8bb95ffe92fc175a5ffb868a [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008, 2012 Obeo.
* 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:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.acceleo.parser.cst.impl;
import java.util.Collection;
import org.eclipse.acceleo.parser.cst.CstPackage;
import org.eclipse.acceleo.parser.cst.Macro;
import org.eclipse.acceleo.parser.cst.ModuleElement;
import org.eclipse.acceleo.parser.cst.Variable;
import org.eclipse.acceleo.parser.cst.VisibilityKind;
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.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Macro</b></em>'. <!-- end-user-doc
* -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.acceleo.parser.cst.impl.MacroImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.acceleo.parser.cst.impl.MacroImpl#getVisibility <em>Visibility</em>}</li>
* <li>{@link org.eclipse.acceleo.parser.cst.impl.MacroImpl#getParameter <em>Parameter</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class MacroImpl extends BlockImpl implements Macro {
/**
* 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 default value of the '{@link #getVisibility() <em>Visibility</em>}' attribute. <!-- begin-user-doc
* --> <!-- end-user-doc -->
*
* @see #getVisibility()
* @generated
* @ordered
*/
protected static final VisibilityKind VISIBILITY_EDEFAULT = VisibilityKind.PRIVATE;
/**
* The cached value of the '{@link #getVisibility() <em>Visibility</em>}' attribute. <!-- begin-user-doc
* --> <!-- end-user-doc -->
*
* @see #getVisibility()
* @generated
* @ordered
*/
protected VisibilityKind visibility = VISIBILITY_EDEFAULT;
/**
* The cached value of the '{@link #getParameter() <em>Parameter</em>}' containment reference list. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @see #getParameter()
* @generated
* @ordered
*/
protected EList<Variable> parameter;
/**
* The default value of the '{@link #getType() <em>Type</em>}' attribute. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @see #getType()
* @generated
* @ordered
*/
protected static final String TYPE_EDEFAULT = null;
/**
* The cached value of the '{@link #getType() <em>Type</em>}' attribute. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @see #getType()
* @generated
* @ordered
*/
protected String type = TYPE_EDEFAULT;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected MacroImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return CstPackage.Literals.MACRO;
}
/**
* <!-- 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, CstPackage.MACRO__NAME, oldName, name));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public VisibilityKind getVisibility() {
return visibility;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setVisibility(VisibilityKind newVisibility) {
VisibilityKind oldVisibility = visibility;
visibility = newVisibility == null ? VISIBILITY_EDEFAULT : newVisibility;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CstPackage.MACRO__VISIBILITY,
oldVisibility, visibility));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public EList<Variable> getParameter() {
if (parameter == null) {
parameter = new EObjectContainmentEList<Variable>(Variable.class, this,
CstPackage.MACRO__PARAMETER);
}
return parameter;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public String getType() {
return type;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setType(String newType) {
String oldType = type;
type = newType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CstPackage.MACRO__TYPE, oldType, type));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CstPackage.MACRO__PARAMETER:
return ((InternalEList<?>)getParameter()).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 CstPackage.MACRO__NAME:
return getName();
case CstPackage.MACRO__VISIBILITY:
return getVisibility();
case CstPackage.MACRO__PARAMETER:
return getParameter();
case CstPackage.MACRO__TYPE:
return getType();
}
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 CstPackage.MACRO__NAME:
setName((String)newValue);
return;
case CstPackage.MACRO__VISIBILITY:
setVisibility((VisibilityKind)newValue);
return;
case CstPackage.MACRO__PARAMETER:
getParameter().clear();
getParameter().addAll((Collection<? extends Variable>)newValue);
return;
case CstPackage.MACRO__TYPE:
setType((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CstPackage.MACRO__NAME:
setName(NAME_EDEFAULT);
return;
case CstPackage.MACRO__VISIBILITY:
setVisibility(VISIBILITY_EDEFAULT);
return;
case CstPackage.MACRO__PARAMETER:
getParameter().clear();
return;
case CstPackage.MACRO__TYPE:
setType(TYPE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CstPackage.MACRO__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case CstPackage.MACRO__VISIBILITY:
return visibility != VISIBILITY_EDEFAULT;
case CstPackage.MACRO__PARAMETER:
return parameter != null && !parameter.isEmpty();
case CstPackage.MACRO__TYPE:
return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == ModuleElement.class) {
switch (derivedFeatureID) {
case CstPackage.MACRO__NAME:
return CstPackage.MODULE_ELEMENT__NAME;
case CstPackage.MACRO__VISIBILITY:
return CstPackage.MODULE_ELEMENT__VISIBILITY;
default:
return -1;
}
}
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
if (baseClass == ModuleElement.class) {
switch (baseFeatureID) {
case CstPackage.MODULE_ELEMENT__NAME:
return CstPackage.MACRO__NAME;
case CstPackage.MODULE_ELEMENT__VISIBILITY:
return CstPackage.MACRO__VISIBILITY;
default:
return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public String toString() {
if (eIsProxy())
return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (name: "); //$NON-NLS-1$
result.append(name);
result.append(", visibility: "); //$NON-NLS-1$
result.append(visibility);
result.append(", type: "); //$NON-NLS-1$
result.append(type);
result.append(')');
return result.toString();
}
} // MacroImpl