blob: a0e4b64985a73d70888e464eee511d4b1ff21b18 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.mdht.uml.cda.impl;
import java.util.Collection;
import java.util.Map;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.DiagnosticChain;
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 org.eclipse.mdht.uml.cda.Birthplace;
import org.eclipse.mdht.uml.cda.CDAPackage;
import org.eclipse.mdht.uml.cda.InfrastructureRootTypeId;
import org.eclipse.mdht.uml.cda.Place;
import org.eclipse.mdht.uml.cda.operations.BirthplaceOperations;
import org.eclipse.mdht.uml.hl7.datatypes.CS;
import org.eclipse.mdht.uml.hl7.datatypes.II;
import org.eclipse.mdht.uml.hl7.rim.impl.RoleImpl;
import org.eclipse.mdht.uml.hl7.vocab.NullFlavor;
import org.eclipse.mdht.uml.hl7.vocab.RoleClass;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Birthplace</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.mdht.uml.cda.impl.BirthplaceImpl#getRealmCodes <em>Realm Code</em>}</li>
* <li>{@link org.eclipse.mdht.uml.cda.impl.BirthplaceImpl#getTypeId <em>Type Id</em>}</li>
* <li>{@link org.eclipse.mdht.uml.cda.impl.BirthplaceImpl#getTemplateIds <em>Template Id</em>}</li>
* <li>{@link org.eclipse.mdht.uml.cda.impl.BirthplaceImpl#getPlace <em>Place</em>}</li>
* <li>{@link org.eclipse.mdht.uml.cda.impl.BirthplaceImpl#getNullFlavor <em>Null Flavor</em>}</li>
* <li>{@link org.eclipse.mdht.uml.cda.impl.BirthplaceImpl#getClassCode <em>Class Code</em>}</li>
* </ul>
*
* @generated
*/
public class BirthplaceImpl extends RoleImpl implements Birthplace {
/**
* The cached value of the '{@link #getRealmCodes() <em>Realm Code</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getRealmCodes()
* @generated
* @ordered
*/
protected EList<CS> realmCodes;
/**
* The cached value of the '{@link #getTypeId() <em>Type Id</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTypeId()
* @generated
* @ordered
*/
protected InfrastructureRootTypeId typeId;
/**
* The cached value of the '{@link #getTemplateIds() <em>Template Id</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTemplateIds()
* @generated
* @ordered
*/
protected EList<II> templateIds;
/**
* The cached value of the '{@link #getPlace() <em>Place</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPlace()
* @generated
* @ordered
*/
protected Place place;
/**
* The default value of the '{@link #getNullFlavor() <em>Null Flavor</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getNullFlavor()
* @generated
* @ordered
*/
protected static final NullFlavor NULL_FLAVOR_EDEFAULT = NullFlavor.ASKU;
/**
* The cached value of the '{@link #getNullFlavor() <em>Null Flavor</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getNullFlavor()
* @generated
* @ordered
*/
protected NullFlavor nullFlavor = NULL_FLAVOR_EDEFAULT;
/**
* This is true if the Null Flavor attribute has been set.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
protected boolean nullFlavorESet;
/**
* The default value of the '{@link #getClassCode() <em>Class Code</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getClassCode()
* @generated
* @ordered
*/
protected static final RoleClass CLASS_CODE_EDEFAULT = RoleClass.BIRTHPL;
/**
* The cached value of the '{@link #getClassCode() <em>Class Code</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getClassCode()
* @generated
* @ordered
*/
protected RoleClass classCode = CLASS_CODE_EDEFAULT;
/**
* This is true if the Class Code attribute has been set.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
protected boolean classCodeESet;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected BirthplaceImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CDAPackage.Literals.BIRTHPLACE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<CS> getRealmCodes() {
if (realmCodes == null) {
realmCodes = new EObjectContainmentEList<>(CS.class, this, CDAPackage.BIRTHPLACE__REALM_CODE);
}
return realmCodes;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public InfrastructureRootTypeId getTypeId() {
return typeId;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTypeId(InfrastructureRootTypeId newTypeId, NotificationChain msgs) {
InfrastructureRootTypeId oldTypeId = typeId;
typeId = newTypeId;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(
this, Notification.SET, CDAPackage.BIRTHPLACE__TYPE_ID, oldTypeId, newTypeId);
if (msgs == null) {
msgs = notification;
} else {
msgs.add(notification);
}
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setTypeId(InfrastructureRootTypeId newTypeId) {
if (newTypeId != typeId) {
NotificationChain msgs = null;
if (typeId != null) {
msgs = ((InternalEObject) typeId).eInverseRemove(
this, EOPPOSITE_FEATURE_BASE - CDAPackage.BIRTHPLACE__TYPE_ID, null, msgs);
}
if (newTypeId != null) {
msgs = ((InternalEObject) newTypeId).eInverseAdd(
this, EOPPOSITE_FEATURE_BASE - CDAPackage.BIRTHPLACE__TYPE_ID, null, msgs);
}
msgs = basicSetTypeId(newTypeId, msgs);
if (msgs != null) {
msgs.dispatch();
}
} else if (eNotificationRequired()) {
eNotify(
new ENotificationImpl(this, Notification.SET, CDAPackage.BIRTHPLACE__TYPE_ID, newTypeId, newTypeId));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<II> getTemplateIds() {
if (templateIds == null) {
templateIds = new EObjectContainmentEList<>(II.class, this, CDAPackage.BIRTHPLACE__TEMPLATE_ID);
}
return templateIds;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Place getPlace() {
return place;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetPlace(Place newPlace, NotificationChain msgs) {
Place oldPlace = place;
place = newPlace;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(
this, Notification.SET, CDAPackage.BIRTHPLACE__PLACE, oldPlace, newPlace);
if (msgs == null) {
msgs = notification;
} else {
msgs.add(notification);
}
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setPlace(Place newPlace) {
if (newPlace != place) {
NotificationChain msgs = null;
if (place != null) {
msgs = ((InternalEObject) place).eInverseRemove(
this, EOPPOSITE_FEATURE_BASE - CDAPackage.BIRTHPLACE__PLACE, null, msgs);
}
if (newPlace != null) {
msgs = ((InternalEObject) newPlace).eInverseAdd(
this, EOPPOSITE_FEATURE_BASE - CDAPackage.BIRTHPLACE__PLACE, null, msgs);
}
msgs = basicSetPlace(newPlace, msgs);
if (msgs != null) {
msgs.dispatch();
}
} else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, CDAPackage.BIRTHPLACE__PLACE, newPlace, newPlace));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NullFlavor getNullFlavor() {
return nullFlavor;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setNullFlavor(NullFlavor newNullFlavor) {
NullFlavor oldNullFlavor = nullFlavor;
nullFlavor = newNullFlavor == null
? NULL_FLAVOR_EDEFAULT
: newNullFlavor;
boolean oldNullFlavorESet = nullFlavorESet;
nullFlavorESet = true;
if (eNotificationRequired()) {
eNotify(
new ENotificationImpl(
this, Notification.SET, CDAPackage.BIRTHPLACE__NULL_FLAVOR, oldNullFlavor, nullFlavor,
!oldNullFlavorESet));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void unsetNullFlavor() {
NullFlavor oldNullFlavor = nullFlavor;
boolean oldNullFlavorESet = nullFlavorESet;
nullFlavor = NULL_FLAVOR_EDEFAULT;
nullFlavorESet = false;
if (eNotificationRequired()) {
eNotify(
new ENotificationImpl(
this, Notification.UNSET, CDAPackage.BIRTHPLACE__NULL_FLAVOR, oldNullFlavor, NULL_FLAVOR_EDEFAULT,
oldNullFlavorESet));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean isSetNullFlavor() {
return nullFlavorESet;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public RoleClass getClassCode() {
return classCode;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setClassCode(RoleClass newClassCode) {
RoleClass oldClassCode = classCode;
classCode = newClassCode == null
? CLASS_CODE_EDEFAULT
: newClassCode;
boolean oldClassCodeESet = classCodeESet;
classCodeESet = true;
if (eNotificationRequired()) {
eNotify(
new ENotificationImpl(
this, Notification.SET, CDAPackage.BIRTHPLACE__CLASS_CODE, oldClassCode, classCode,
!oldClassCodeESet));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void unsetClassCode() {
RoleClass oldClassCode = classCode;
boolean oldClassCodeESet = classCodeESet;
classCode = CLASS_CODE_EDEFAULT;
classCodeESet = false;
if (eNotificationRequired()) {
eNotify(
new ENotificationImpl(
this, Notification.UNSET, CDAPackage.BIRTHPLACE__CLASS_CODE, oldClassCode, CLASS_CODE_EDEFAULT,
oldClassCodeESet));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean isSetClassCode() {
return classCodeESet;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean validateClassCode(DiagnosticChain diagnostics, Map<Object, Object> context) {
return BirthplaceOperations.validateClassCode(this, diagnostics, context);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CDAPackage.BIRTHPLACE__REALM_CODE:
return ((InternalEList<?>) getRealmCodes()).basicRemove(otherEnd, msgs);
case CDAPackage.BIRTHPLACE__TYPE_ID:
return basicSetTypeId(null, msgs);
case CDAPackage.BIRTHPLACE__TEMPLATE_ID:
return ((InternalEList<?>) getTemplateIds()).basicRemove(otherEnd, msgs);
case CDAPackage.BIRTHPLACE__PLACE:
return basicSetPlace(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 CDAPackage.BIRTHPLACE__REALM_CODE:
return getRealmCodes();
case CDAPackage.BIRTHPLACE__TYPE_ID:
return getTypeId();
case CDAPackage.BIRTHPLACE__TEMPLATE_ID:
return getTemplateIds();
case CDAPackage.BIRTHPLACE__PLACE:
return getPlace();
case CDAPackage.BIRTHPLACE__NULL_FLAVOR:
return getNullFlavor();
case CDAPackage.BIRTHPLACE__CLASS_CODE:
return getClassCode();
}
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 CDAPackage.BIRTHPLACE__REALM_CODE:
getRealmCodes().clear();
getRealmCodes().addAll((Collection<? extends CS>) newValue);
return;
case CDAPackage.BIRTHPLACE__TYPE_ID:
setTypeId((InfrastructureRootTypeId) newValue);
return;
case CDAPackage.BIRTHPLACE__TEMPLATE_ID:
getTemplateIds().clear();
getTemplateIds().addAll((Collection<? extends II>) newValue);
return;
case CDAPackage.BIRTHPLACE__PLACE:
setPlace((Place) newValue);
return;
case CDAPackage.BIRTHPLACE__NULL_FLAVOR:
setNullFlavor((NullFlavor) newValue);
return;
case CDAPackage.BIRTHPLACE__CLASS_CODE:
setClassCode((RoleClass) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CDAPackage.BIRTHPLACE__REALM_CODE:
getRealmCodes().clear();
return;
case CDAPackage.BIRTHPLACE__TYPE_ID:
setTypeId((InfrastructureRootTypeId) null);
return;
case CDAPackage.BIRTHPLACE__TEMPLATE_ID:
getTemplateIds().clear();
return;
case CDAPackage.BIRTHPLACE__PLACE:
setPlace((Place) null);
return;
case CDAPackage.BIRTHPLACE__NULL_FLAVOR:
unsetNullFlavor();
return;
case CDAPackage.BIRTHPLACE__CLASS_CODE:
unsetClassCode();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CDAPackage.BIRTHPLACE__REALM_CODE:
return realmCodes != null && !realmCodes.isEmpty();
case CDAPackage.BIRTHPLACE__TYPE_ID:
return typeId != null;
case CDAPackage.BIRTHPLACE__TEMPLATE_ID:
return templateIds != null && !templateIds.isEmpty();
case CDAPackage.BIRTHPLACE__PLACE:
return place != null;
case CDAPackage.BIRTHPLACE__NULL_FLAVOR:
return isSetNullFlavor();
case CDAPackage.BIRTHPLACE__CLASS_CODE:
return isSetClassCode();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) {
return super.toString();
}
StringBuilder result = new StringBuilder(super.toString());
result.append(" (nullFlavor: ");
if (nullFlavorESet) {
result.append(nullFlavor);
} else {
result.append("<unset>");
}
result.append(", classCode: ");
if (classCodeESet) {
result.append(classCode);
} else {
result.append("<unset>");
}
result.append(')');
return result.toString();
}
} // BirthplaceImpl