PropertyNameHolderImpl.java

/**
 * AADL-BA-FrontEnd
 * 
 * Copyright (c) 2011-2021 TELECOM ParisTech and CNRS
 * 
 * TELECOM ParisTech/LTCI
 * 
 * Authors: see AUTHORS
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the Eclipse Public License as published by Eclipse, either
 * version 2.0 of the License, or (at your option) any later version. 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 Eclipse Public License for
 * more details. You should have received a copy of the Eclipse Public License
 * along with this program. If not, see
 * https://www.eclipse.org/legal/epl-2.0/
 */
package org.osate.ba.aadlba.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.osate.ba.aadlba.AadlBaPackage;
import org.osate.ba.aadlba.PropertyElementHolder;
import org.osate.ba.aadlba.PropertyNameField;
import org.osate.ba.aadlba.PropertyNameHolder;
import org.osate.ba.utils.visitor.IBAVisitor;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Property Name Holder</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.osate.ba.aadlba.impl.PropertyNameHolderImpl#getProperty <em>Property</em>}</li>
 *   <li>{@link org.osate.ba.aadlba.impl.PropertyNameHolderImpl#getField <em>Field</em>}</li>
 * </ul>
 *
 * @generated
 */
public class PropertyNameHolderImpl extends BehaviorElementImpl implements PropertyNameHolder {
	/**
	 * The cached value of the '{@link #getProperty() <em>Property</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProperty()
	 * @generated
	 * @ordered
	 */
	protected PropertyElementHolder property;

	/**
	 * The cached value of the '{@link #getField() <em>Field</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getField()
	 * @generated
	 * @ordered
	 */
	protected PropertyNameField field;

	/**
	 * This is true if the Field containment reference has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean fieldESet;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PropertyNameHolderImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return AadlBaPackage.Literals.PROPERTY_NAME_HOLDER;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public PropertyElementHolder getProperty() {
		return property;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetProperty(PropertyElementHolder newProperty, NotificationChain msgs) {
		PropertyElementHolder oldProperty = property;
		property = newProperty;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
					AadlBaPackage.PROPERTY_NAME_HOLDER__PROPERTY, oldProperty, newProperty);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setProperty(PropertyElementHolder newProperty) {
		if (newProperty != property) {
			NotificationChain msgs = null;
			if (property != null)
				msgs = ((InternalEObject) property).eInverseRemove(this,
						EOPPOSITE_FEATURE_BASE - AadlBaPackage.PROPERTY_NAME_HOLDER__PROPERTY, null, msgs);
			if (newProperty != null)
				msgs = ((InternalEObject) newProperty).eInverseAdd(this,
						EOPPOSITE_FEATURE_BASE - AadlBaPackage.PROPERTY_NAME_HOLDER__PROPERTY, null, msgs);
			msgs = basicSetProperty(newProperty, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, AadlBaPackage.PROPERTY_NAME_HOLDER__PROPERTY,
					newProperty, newProperty));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public PropertyNameField getField() {
		return field;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetField(PropertyNameField newField, NotificationChain msgs) {
		PropertyNameField oldField = field;
		field = newField;
		boolean oldFieldESet = fieldESet;
		fieldESet = true;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
					AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD, oldField, newField, !oldFieldESet);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void setField(PropertyNameField newField) {
		if (newField != field) {
			NotificationChain msgs = null;
			if (field != null)
				msgs = ((InternalEObject) field).eInverseRemove(this,
						EOPPOSITE_FEATURE_BASE - AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD, null, msgs);
			if (newField != null)
				msgs = ((InternalEObject) newField).eInverseAdd(this,
						EOPPOSITE_FEATURE_BASE - AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD, null, msgs);
			msgs = basicSetField(newField, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else {
			boolean oldFieldESet = fieldESet;
			fieldESet = true;
			if (eNotificationRequired())
				eNotify(new ENotificationImpl(this, Notification.SET, AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD,
						newField, newField, !oldFieldESet));
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicUnsetField(NotificationChain msgs) {
		PropertyNameField oldField = field;
		field = null;
		boolean oldFieldESet = fieldESet;
		fieldESet = false;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.UNSET,
					AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD, oldField, null, oldFieldESet);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void unsetField() {
		if (field != null) {
			NotificationChain msgs = null;
			msgs = ((InternalEObject) field).eInverseRemove(this,
					EOPPOSITE_FEATURE_BASE - AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD, null, msgs);
			msgs = basicUnsetField(msgs);
			if (msgs != null)
				msgs.dispatch();
		} else {
			boolean oldFieldESet = fieldESet;
			fieldESet = false;
			if (eNotificationRequired())
				eNotify(new ENotificationImpl(this, Notification.UNSET, AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD, null,
						null, oldFieldESet));
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isSetField() {
		return fieldESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
		case AadlBaPackage.PROPERTY_NAME_HOLDER__PROPERTY:
			return basicSetProperty(null, msgs);
		case AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD:
			return basicUnsetField(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 AadlBaPackage.PROPERTY_NAME_HOLDER__PROPERTY:
			return getProperty();
		case AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD:
			return getField();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case AadlBaPackage.PROPERTY_NAME_HOLDER__PROPERTY:
			setProperty((PropertyElementHolder) newValue);
			return;
		case AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD:
			setField((PropertyNameField) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case AadlBaPackage.PROPERTY_NAME_HOLDER__PROPERTY:
			setProperty((PropertyElementHolder) null);
			return;
		case AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD:
			unsetField();
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case AadlBaPackage.PROPERTY_NAME_HOLDER__PROPERTY:
			return property != null;
		case AadlBaPackage.PROPERTY_NAME_HOLDER__FIELD:
			return isSetField();
		}
		return super.eIsSet(featureID);
	}

	public void accept(IBAVisitor visitor) {
		visitor.visit(this);
	}

} // PropertyNameHolderImpl