| /** |
| * Copyright (c) 2020 CEA LIST, Committer Name, and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * CEA LIST - Initial API and implementation |
| * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr |
| * Gabriel Pedroza (CEA LIST) gabriel.pedroza@cea.fr |
| * |
| */ |
| package org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.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.impl.MinimalEObjectImpl; |
| |
| import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.Consent; |
| import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.DataSubject; |
| import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.Pdp4engCommonGDPRPackage; |
| import org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.Purpose; |
| |
| import org.eclipse.uml2.uml.NamedElement; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Consent</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.impl.ConsentImpl#getBase_NamedElement <em>Base Named Element</em>}</li> |
| * <li>{@link org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.impl.ConsentImpl#getPurpose <em>Purpose</em>}</li> |
| * <li>{@link org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.impl.ConsentImpl#getDatasubject <em>Datasubject</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class ConsentImpl extends MinimalEObjectImpl.Container implements Consent { |
| /** |
| * The cached value of the '{@link #getBase_NamedElement() <em>Base Named Element</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getBase_NamedElement() |
| * @generated |
| * @ordered |
| */ |
| protected NamedElement base_NamedElement; |
| |
| /** |
| * The cached value of the '{@link #getPurpose() <em>Purpose</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getPurpose() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Purpose> purpose; |
| |
| /** |
| * The cached value of the '{@link #getDatasubject() <em>Datasubject</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getDatasubject() |
| * @generated |
| * @ordered |
| */ |
| protected DataSubject datasubject; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| protected ConsentImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return Pdp4engCommonGDPRPackage.Literals.CONSENT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public NamedElement getBase_NamedElement() { |
| if (base_NamedElement != null && base_NamedElement.eIsProxy()) { |
| InternalEObject oldBase_NamedElement = (InternalEObject) base_NamedElement; |
| base_NamedElement = (NamedElement) eResolveProxy(oldBase_NamedElement); |
| if (base_NamedElement != oldBase_NamedElement) { |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, Pdp4engCommonGDPRPackage.CONSENT__BASE_NAMED_ELEMENT, oldBase_NamedElement, base_NamedElement)); |
| } |
| } |
| } |
| return base_NamedElement; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public NamedElement basicGetBase_NamedElement() { |
| return base_NamedElement; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setBase_NamedElement(NamedElement newBase_NamedElement) { |
| NamedElement oldBase_NamedElement = base_NamedElement; |
| base_NamedElement = newBase_NamedElement; |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, Pdp4engCommonGDPRPackage.CONSENT__BASE_NAMED_ELEMENT, oldBase_NamedElement, base_NamedElement)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public EList<Purpose> getPurpose() { |
| if (purpose == null) { |
| purpose = new EObjectWithInverseResolvingEList<>(Purpose.class, this, Pdp4engCommonGDPRPackage.CONSENT__PURPOSE, Pdp4engCommonGDPRPackage.PURPOSE__CONSENT); |
| } |
| return purpose; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public DataSubject getDatasubject() { |
| if (datasubject != null && datasubject.eIsProxy()) { |
| InternalEObject oldDatasubject = (InternalEObject) datasubject; |
| datasubject = (DataSubject) eResolveProxy(oldDatasubject); |
| if (datasubject != oldDatasubject) { |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, Pdp4engCommonGDPRPackage.CONSENT__DATASUBJECT, oldDatasubject, datasubject)); |
| } |
| } |
| } |
| return datasubject; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public DataSubject basicGetDatasubject() { |
| return datasubject; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public NotificationChain basicSetDatasubject(DataSubject newDatasubject, NotificationChain msgs) { |
| DataSubject oldDatasubject = datasubject; |
| datasubject = newDatasubject; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Pdp4engCommonGDPRPackage.CONSENT__DATASUBJECT, oldDatasubject, newDatasubject); |
| if (msgs == null) { |
| msgs = notification; |
| } else { |
| msgs.add(notification); |
| } |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setDatasubject(DataSubject newDatasubject) { |
| if (newDatasubject != datasubject) { |
| NotificationChain msgs = null; |
| if (datasubject != null) { |
| msgs = ((InternalEObject) datasubject).eInverseRemove(this, Pdp4engCommonGDPRPackage.DATA_SUBJECT__GIVEN_CONSENT, DataSubject.class, msgs); |
| } |
| if (newDatasubject != null) { |
| msgs = ((InternalEObject) newDatasubject).eInverseAdd(this, Pdp4engCommonGDPRPackage.DATA_SUBJECT__GIVEN_CONSENT, DataSubject.class, msgs); |
| } |
| msgs = basicSetDatasubject(newDatasubject, msgs); |
| if (msgs != null) { |
| msgs.dispatch(); |
| } |
| } else if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, Pdp4engCommonGDPRPackage.CONSENT__DATASUBJECT, newDatasubject, newDatasubject)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case Pdp4engCommonGDPRPackage.CONSENT__PURPOSE: |
| return ((InternalEList<InternalEObject>) (InternalEList<?>) getPurpose()).basicAdd(otherEnd, msgs); |
| case Pdp4engCommonGDPRPackage.CONSENT__DATASUBJECT: |
| if (datasubject != null) { |
| msgs = ((InternalEObject) datasubject).eInverseRemove(this, Pdp4engCommonGDPRPackage.DATA_SUBJECT__GIVEN_CONSENT, DataSubject.class, msgs); |
| } |
| return basicSetDatasubject((DataSubject) 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 Pdp4engCommonGDPRPackage.CONSENT__PURPOSE: |
| return ((InternalEList<?>) getPurpose()).basicRemove(otherEnd, msgs); |
| case Pdp4engCommonGDPRPackage.CONSENT__DATASUBJECT: |
| return basicSetDatasubject(null, 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 Pdp4engCommonGDPRPackage.CONSENT__BASE_NAMED_ELEMENT: |
| if (resolve) { |
| return getBase_NamedElement(); |
| } |
| return basicGetBase_NamedElement(); |
| case Pdp4engCommonGDPRPackage.CONSENT__PURPOSE: |
| return getPurpose(); |
| case Pdp4engCommonGDPRPackage.CONSENT__DATASUBJECT: |
| if (resolve) { |
| return getDatasubject(); |
| } |
| return basicGetDatasubject(); |
| } |
| 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 Pdp4engCommonGDPRPackage.CONSENT__BASE_NAMED_ELEMENT: |
| setBase_NamedElement((NamedElement) newValue); |
| return; |
| case Pdp4engCommonGDPRPackage.CONSENT__PURPOSE: |
| getPurpose().clear(); |
| getPurpose().addAll((Collection<? extends Purpose>) newValue); |
| return; |
| case Pdp4engCommonGDPRPackage.CONSENT__DATASUBJECT: |
| setDatasubject((DataSubject) newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case Pdp4engCommonGDPRPackage.CONSENT__BASE_NAMED_ELEMENT: |
| setBase_NamedElement((NamedElement) null); |
| return; |
| case Pdp4engCommonGDPRPackage.CONSENT__PURPOSE: |
| getPurpose().clear(); |
| return; |
| case Pdp4engCommonGDPRPackage.CONSENT__DATASUBJECT: |
| setDatasubject((DataSubject) null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case Pdp4engCommonGDPRPackage.CONSENT__BASE_NAMED_ELEMENT: |
| return base_NamedElement != null; |
| case Pdp4engCommonGDPRPackage.CONSENT__PURPOSE: |
| return purpose != null && !purpose.isEmpty(); |
| case Pdp4engCommonGDPRPackage.CONSENT__DATASUBJECT: |
| return datasubject != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| } // ConsentImpl |