/* license-start * * Copyright (C) 2008 - 2013 Crispico, <http://www.crispico.com/>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details, at <http://www.gnu.org/licenses/>. * * Contributors: * Crispico - Initial API and implementation * * license-end */ /** * <copyright> * </copyright> * * $Id$ */ package com.crispico.flower.mp.model.astcache.code.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.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; import com.crispico.flower.mp.model.astcache.code.AstCacheCodePackage; import com.crispico.flower.mp.model.astcache.code.ExtendedModifier; import com.crispico.flower.mp.model.astcache.code.ModifiableElement; import com.crispico.flower.mp.model.astcache.code.Parameter; import com.crispico.flower.mp.model.astcache.code.TypedElement; import com.crispico.flower.mp.model.codesync.impl.AstCacheElementImpl; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Parameter</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link com.crispico.flower.mp.model.astcache.code.impl.ParameterImpl#getModifiers <em>Modifiers</em>}</li> * <li>{@link com.crispico.flower.mp.model.astcache.code.impl.ParameterImpl#getType <em>Type</em>}</li> * <li>{@link com.crispico.flower.mp.model.astcache.code.impl.ParameterImpl#getName <em>Name</em>}</li> * </ul> * </p> * * @generated */ public class ParameterImpl extends AstCacheElementImpl implements Parameter { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ private static final long serialVersionUID = 1L; /** * The cached value of the '{@link #getModifiers() <em>Modifiers</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getModifiers() * @generated * @ordered */ protected EList<ExtendedModifier> modifiers; /** * 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; /** * 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; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ParameterImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return AstCacheCodePackage.Literals.PARAMETER; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<ExtendedModifier> getModifiers() { if (modifiers == null) { modifiers = new EObjectContainmentEList<ExtendedModifier>(ExtendedModifier.class, this, AstCacheCodePackage.PARAMETER__MODIFIERS); } return modifiers; } /** * <!-- 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, AstCacheCodePackage.PARAMETER__TYPE, oldType, type)); } /** * <!-- 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, AstCacheCodePackage.PARAMETER__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case AstCacheCodePackage.PARAMETER__MODIFIERS: return ((InternalEList<?>)getModifiers()).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 AstCacheCodePackage.PARAMETER__MODIFIERS: return getModifiers(); case AstCacheCodePackage.PARAMETER__TYPE: return getType(); case AstCacheCodePackage.PARAMETER__NAME: return getName(); } 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 AstCacheCodePackage.PARAMETER__MODIFIERS: getModifiers().clear(); getModifiers().addAll((Collection<? extends ExtendedModifier>)newValue); return; case AstCacheCodePackage.PARAMETER__TYPE: setType((String)newValue); return; case AstCacheCodePackage.PARAMETER__NAME: setName((String)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case AstCacheCodePackage.PARAMETER__MODIFIERS: getModifiers().clear(); return; case AstCacheCodePackage.PARAMETER__TYPE: setType(TYPE_EDEFAULT); return; case AstCacheCodePackage.PARAMETER__NAME: setName(NAME_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case AstCacheCodePackage.PARAMETER__MODIFIERS: return modifiers != null && !modifiers.isEmpty(); case AstCacheCodePackage.PARAMETER__TYPE: return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type); case AstCacheCodePackage.PARAMETER__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { if (baseClass == ModifiableElement.class) { switch (derivedFeatureID) { case AstCacheCodePackage.PARAMETER__MODIFIERS: return AstCacheCodePackage.MODIFIABLE_ELEMENT__MODIFIERS; default: return -1; } } if (baseClass == TypedElement.class) { switch (derivedFeatureID) { case AstCacheCodePackage.PARAMETER__TYPE: return AstCacheCodePackage.TYPED_ELEMENT__TYPE; 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 == ModifiableElement.class) { switch (baseFeatureID) { case AstCacheCodePackage.MODIFIABLE_ELEMENT__MODIFIERS: return AstCacheCodePackage.PARAMETER__MODIFIERS; default: return -1; } } if (baseClass == TypedElement.class) { switch (baseFeatureID) { case AstCacheCodePackage.TYPED_ELEMENT__TYPE: return AstCacheCodePackage.PARAMETER__TYPE; 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(" (type: "); result.append(type); result.append(", name: "); result.append(name); result.append(')'); return result.toString(); } /** * @author Mariana Gheorghe * @generated NOT */ @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj instanceof Parameter) { return equal(this.getName(), ((Parameter) obj).getName()) && equal(this.getType(), ((Parameter) obj).getType()) && this.getModifiers().equals(((Parameter) obj).getModifiers()); } return false; } /** * @author Mariana Gheorghe * @generated NOT */ private boolean equal(String a, String b) { if (a == null) { return (b == null); } return a.equals(b); } } //ParameterImpl