blob: fec4926e4f39907d2b9956d7882a5f6ff66e4421 [file] [log] [blame]
/**
* 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.Contract;
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.PersonalData;
import org.eclipse.uml2.uml.NamedElement;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Data Subject</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.impl.DataSubjectImpl#getBase_NamedElement <em>Base Named Element</em>}</li>
* <li>{@link org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.impl.DataSubjectImpl#getGivenConsent <em>Given Consent</em>}</li>
* <li>{@link org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.impl.DataSubjectImpl#getContract <em>Contract</em>}</li>
* <li>{@link org.eclipse.papyrus.pdp4eng.common.profile.pdp4engCommonGDPR.impl.DataSubjectImpl#getPersonalData <em>Personal Data</em>}</li>
* </ul>
*
* @generated
*/
public class DataSubjectImpl extends MinimalEObjectImpl.Container implements DataSubject {
/**
* 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 #getGivenConsent() <em>Given Consent</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getGivenConsent()
* @generated
* @ordered
*/
protected EList<Consent> givenConsent;
/**
* The cached value of the '{@link #getContract() <em>Contract</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getContract()
* @generated
* @ordered
*/
protected Contract contract;
/**
* The cached value of the '{@link #getPersonalData() <em>Personal Data</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPersonalData()
* @generated
* @ordered
*/
protected EList<PersonalData> personalData;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected DataSubjectImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return Pdp4engCommonGDPRPackage.Literals.DATA_SUBJECT;
}
/**
* <!-- 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.DATA_SUBJECT__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.DATA_SUBJECT__BASE_NAMED_ELEMENT, oldBase_NamedElement, base_NamedElement));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<Consent> getGivenConsent() {
if (givenConsent == null) {
givenConsent = new EObjectWithInverseResolvingEList<Consent>(Consent.class, this, Pdp4engCommonGDPRPackage.DATA_SUBJECT__GIVEN_CONSENT, Pdp4engCommonGDPRPackage.CONSENT__DATASUBJECT);
}
return givenConsent;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Contract getContract() {
if (contract != null && contract.eIsProxy()) {
InternalEObject oldContract = (InternalEObject)contract;
contract = (Contract)eResolveProxy(oldContract);
if (contract != oldContract) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, Pdp4engCommonGDPRPackage.DATA_SUBJECT__CONTRACT, oldContract, contract));
}
}
return contract;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Contract basicGetContract() {
return contract;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetContract(Contract newContract, NotificationChain msgs) {
Contract oldContract = contract;
contract = newContract;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Pdp4engCommonGDPRPackage.DATA_SUBJECT__CONTRACT, oldContract, newContract);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setContract(Contract newContract) {
if (newContract != contract) {
NotificationChain msgs = null;
if (contract != null)
msgs = ((InternalEObject)contract).eInverseRemove(this, Pdp4engCommonGDPRPackage.CONTRACT__DATASUBJECT, Contract.class, msgs);
if (newContract != null)
msgs = ((InternalEObject)newContract).eInverseAdd(this, Pdp4engCommonGDPRPackage.CONTRACT__DATASUBJECT, Contract.class, msgs);
msgs = basicSetContract(newContract, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Pdp4engCommonGDPRPackage.DATA_SUBJECT__CONTRACT, newContract, newContract));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<PersonalData> getPersonalData() {
if (personalData == null) {
personalData = new EObjectWithInverseResolvingEList.ManyInverse<PersonalData>(PersonalData.class, this, Pdp4engCommonGDPRPackage.DATA_SUBJECT__PERSONAL_DATA, Pdp4engCommonGDPRPackage.PERSONAL_DATA__RELATED_TO);
}
return personalData;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__GIVEN_CONSENT:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getGivenConsent()).basicAdd(otherEnd, msgs);
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__CONTRACT:
if (contract != null)
msgs = ((InternalEObject)contract).eInverseRemove(this, Pdp4engCommonGDPRPackage.CONTRACT__DATASUBJECT, Contract.class, msgs);
return basicSetContract((Contract)otherEnd, msgs);
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__PERSONAL_DATA:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getPersonalData()).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 Pdp4engCommonGDPRPackage.DATA_SUBJECT__GIVEN_CONSENT:
return ((InternalEList<?>)getGivenConsent()).basicRemove(otherEnd, msgs);
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__CONTRACT:
return basicSetContract(null, msgs);
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__PERSONAL_DATA:
return ((InternalEList<?>)getPersonalData()).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 Pdp4engCommonGDPRPackage.DATA_SUBJECT__BASE_NAMED_ELEMENT:
if (resolve) return getBase_NamedElement();
return basicGetBase_NamedElement();
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__GIVEN_CONSENT:
return getGivenConsent();
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__CONTRACT:
if (resolve) return getContract();
return basicGetContract();
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__PERSONAL_DATA:
return getPersonalData();
}
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.DATA_SUBJECT__BASE_NAMED_ELEMENT:
setBase_NamedElement((NamedElement)newValue);
return;
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__GIVEN_CONSENT:
getGivenConsent().clear();
getGivenConsent().addAll((Collection<? extends Consent>)newValue);
return;
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__CONTRACT:
setContract((Contract)newValue);
return;
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__PERSONAL_DATA:
getPersonalData().clear();
getPersonalData().addAll((Collection<? extends PersonalData>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__BASE_NAMED_ELEMENT:
setBase_NamedElement((NamedElement)null);
return;
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__GIVEN_CONSENT:
getGivenConsent().clear();
return;
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__CONTRACT:
setContract((Contract)null);
return;
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__PERSONAL_DATA:
getPersonalData().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__BASE_NAMED_ELEMENT:
return base_NamedElement != null;
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__GIVEN_CONSENT:
return givenConsent != null && !givenConsent.isEmpty();
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__CONTRACT:
return contract != null;
case Pdp4engCommonGDPRPackage.DATA_SUBJECT__PERSONAL_DATA:
return personalData != null && !personalData.isEmpty();
}
return super.eIsSet(featureID);
}
} //DataSubjectImpl