| /**
|
| * *******************************************************************************
|
| * Copyright (c) 2009, 2019 Mia-Software and others.
|
| * All rights reserved. This program and the accompanying materials
|
| * are made available under the terms of the Eclipse Public License v2.0
|
| * which accompanies this distribution, and is available at
|
| * http://www.eclipse.org/legal/epl-v20.html
|
| *
|
| * Contributors:
|
| *
|
| * Fabien Giquel (Mia-Software) - initial API and implementation
|
| * *******************************************************************************
|
| *
|
| * $Id$
|
| */ |
| package org.eclipse.modisco.java.emf.classic.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.EObjectWithInverseResolvingEList;
|
| import org.eclipse.emf.ecore.util.InternalEList;
|
| import org.eclipse.modisco.java.Expression;
|
| import org.eclipse.modisco.java.SingleVariableAccess;
|
| import org.eclipse.modisco.java.VariableDeclaration;
|
| import org.eclipse.modisco.java.emf.classic.JavaPackage;
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * An implementation of the model object '<em><b>Variable Declaration</b></em>'.
|
| * <!-- end-user-doc -->
|
| * <p>
|
| * The following features are implemented:
|
| * <ul>
|
| * <li>{@link org.eclipse.modisco.java.emf.classic.impl.VariableDeclarationImpl#getExtraArrayDimensions <em>Extra Array Dimensions</em>}</li>
|
| * <li>{@link org.eclipse.modisco.java.emf.classic.impl.VariableDeclarationImpl#getInitializer <em>Initializer</em>}</li>
|
| * <li>{@link org.eclipse.modisco.java.emf.classic.impl.VariableDeclarationImpl#getUsageInVariableAccess <em>Usage In Variable Access</em>}</li>
|
| * </ul>
|
| * </p>
|
| *
|
| * @generated
|
| */
|
| public abstract class VariableDeclarationImpl extends NamedElementImpl implements VariableDeclaration {
|
| /**
|
| * The default value of the '{@link #getExtraArrayDimensions() <em>Extra Array Dimensions</em>}' attribute.
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @see #getExtraArrayDimensions()
|
| * @generated
|
| * @ordered
|
| */
|
| protected static final int EXTRA_ARRAY_DIMENSIONS_EDEFAULT = 0;
|
|
|
| /**
|
| * The cached value of the '{@link #getExtraArrayDimensions() <em>Extra Array Dimensions</em>}' attribute.
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @see #getExtraArrayDimensions()
|
| * @generated
|
| * @ordered
|
| */
|
| protected int extraArrayDimensions = EXTRA_ARRAY_DIMENSIONS_EDEFAULT;
|
|
|
| /**
|
| * The cached value of the '{@link #getInitializer() <em>Initializer</em>}' containment reference.
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @see #getInitializer()
|
| * @generated
|
| * @ordered
|
| */
|
| protected Expression initializer;
|
|
|
| /**
|
| * The cached value of the '{@link #getUsageInVariableAccess() <em>Usage In Variable Access</em>}' reference list.
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @see #getUsageInVariableAccess()
|
| * @generated
|
| * @ordered
|
| */
|
| protected EList<SingleVariableAccess> usageInVariableAccess;
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| protected VariableDeclarationImpl() {
|
| super();
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| @Override
|
| protected EClass eStaticClass() {
|
| return JavaPackage.eINSTANCE.getVariableDeclaration();
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| public int getExtraArrayDimensions() {
|
| return extraArrayDimensions;
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| public void setExtraArrayDimensions(int newExtraArrayDimensions) {
|
| int oldExtraArrayDimensions = extraArrayDimensions;
|
| extraArrayDimensions = newExtraArrayDimensions;
|
| if (eNotificationRequired())
|
| eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.VARIABLE_DECLARATION__EXTRA_ARRAY_DIMENSIONS, oldExtraArrayDimensions, extraArrayDimensions));
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| public Expression getInitializer() {
|
| return initializer;
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| public NotificationChain basicSetInitializer(Expression newInitializer, NotificationChain msgs) {
|
| Expression oldInitializer = initializer;
|
| initializer = newInitializer;
|
| if (eNotificationRequired()) {
|
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.VARIABLE_DECLARATION__INITIALIZER, oldInitializer, newInitializer);
|
| if (msgs == null) msgs = notification; else msgs.add(notification);
|
| }
|
| return msgs;
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| public void setInitializer(Expression newInitializer) {
|
| if (newInitializer != initializer) {
|
| NotificationChain msgs = null;
|
| if (initializer != null)
|
| msgs = ((InternalEObject)initializer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.VARIABLE_DECLARATION__INITIALIZER, null, msgs);
|
| if (newInitializer != null)
|
| msgs = ((InternalEObject)newInitializer).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.VARIABLE_DECLARATION__INITIALIZER, null, msgs);
|
| msgs = basicSetInitializer(newInitializer, msgs);
|
| if (msgs != null) msgs.dispatch();
|
| }
|
| else if (eNotificationRequired())
|
| eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.VARIABLE_DECLARATION__INITIALIZER, newInitializer, newInitializer));
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| public EList<SingleVariableAccess> getUsageInVariableAccess() {
|
| if (usageInVariableAccess == null) {
|
| usageInVariableAccess = new EObjectWithInverseResolvingEList<SingleVariableAccess>(SingleVariableAccess.class, this, JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS, JavaPackage.SINGLE_VARIABLE_ACCESS__VARIABLE);
|
| }
|
| return usageInVariableAccess;
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| @SuppressWarnings("unchecked")
|
| @Override
|
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
|
| switch (featureID) {
|
| case JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS:
|
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getUsageInVariableAccess()).basicAdd(otherEnd, msgs);
|
| }
|
| return super.eInverseAdd(otherEnd, featureID, msgs);
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| @Override
|
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
|
| switch (featureID) {
|
| case JavaPackage.VARIABLE_DECLARATION__INITIALIZER:
|
| return basicSetInitializer(null, msgs);
|
| case JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS:
|
| return ((InternalEList<?>)getUsageInVariableAccess()).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 JavaPackage.VARIABLE_DECLARATION__EXTRA_ARRAY_DIMENSIONS:
|
| return getExtraArrayDimensions();
|
| case JavaPackage.VARIABLE_DECLARATION__INITIALIZER:
|
| return getInitializer();
|
| case JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS:
|
| return getUsageInVariableAccess();
|
| }
|
| 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 JavaPackage.VARIABLE_DECLARATION__EXTRA_ARRAY_DIMENSIONS:
|
| setExtraArrayDimensions((Integer)newValue);
|
| return;
|
| case JavaPackage.VARIABLE_DECLARATION__INITIALIZER:
|
| setInitializer((Expression)newValue);
|
| return;
|
| case JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS:
|
| getUsageInVariableAccess().clear();
|
| getUsageInVariableAccess().addAll((Collection<? extends SingleVariableAccess>)newValue);
|
| return;
|
| }
|
| super.eSet(featureID, newValue);
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| @Override
|
| public void eUnset(int featureID) {
|
| switch (featureID) {
|
| case JavaPackage.VARIABLE_DECLARATION__EXTRA_ARRAY_DIMENSIONS:
|
| setExtraArrayDimensions(EXTRA_ARRAY_DIMENSIONS_EDEFAULT);
|
| return;
|
| case JavaPackage.VARIABLE_DECLARATION__INITIALIZER:
|
| setInitializer((Expression)null);
|
| return;
|
| case JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS:
|
| getUsageInVariableAccess().clear();
|
| return;
|
| }
|
| super.eUnset(featureID);
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| @Override
|
| public boolean eIsSet(int featureID) {
|
| switch (featureID) {
|
| case JavaPackage.VARIABLE_DECLARATION__EXTRA_ARRAY_DIMENSIONS:
|
| return extraArrayDimensions != EXTRA_ARRAY_DIMENSIONS_EDEFAULT;
|
| case JavaPackage.VARIABLE_DECLARATION__INITIALIZER:
|
| return initializer != null;
|
| case JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS:
|
| return usageInVariableAccess != null && !usageInVariableAccess.isEmpty();
|
| }
|
| return super.eIsSet(featureID);
|
| }
|
|
|
| /**
|
| * <!-- begin-user-doc -->
|
| * <!-- end-user-doc -->
|
| * @generated
|
| */
|
| @Override
|
| public String toString() {
|
| if (eIsProxy()) return super.toString();
|
|
|
| StringBuffer result = new StringBuffer(super.toString());
|
| result.append(" (extraArrayDimensions: "); //$NON-NLS-1$
|
| result.append(extraArrayDimensions);
|
| result.append(')');
|
| return result.toString();
|
| }
|
|
|
| } //VariableDeclarationImpl
|