blob: b64b09642297f5dc66f001e696e06caa7dc721ba [file] [log] [blame]
/**
* Copyright (c) 2008, 2015 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.e4.ui.model.application.impl;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.eclipse.e4.ui.model.application.MApplicationElement;
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.common.util.EMap;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
import org.eclipse.emf.ecore.util.EcoreEMap;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Element</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationElementImpl#getElementId <em>Element Id</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationElementImpl#getPersistedState <em>Persisted State</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationElementImpl#getTags <em>Tags</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationElementImpl#getContributorURI <em>Contributor URI</em>}</li>
* <li>{@link org.eclipse.e4.ui.model.application.impl.ApplicationElementImpl#getTransientData <em>Transient Data</em>}</li>
* </ul>
*
* @since 1.0
* @generated
*/
public abstract class ApplicationElementImpl extends org.eclipse.emf.ecore.impl.MinimalEObjectImpl.Container implements MApplicationElement {
/**
* The default value of the '{@link #getElementId() <em>Element Id</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getElementId()
* @generated
* @ordered
*/
protected static final String ELEMENT_ID_EDEFAULT = null;
/**
* The cached value of the '{@link #getElementId() <em>Element Id</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getElementId()
* @generated
* @ordered
*/
protected String elementId = ELEMENT_ID_EDEFAULT;
/**
* The cached value of the '{@link #getPersistedState() <em>Persisted State</em>}' map.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPersistedState()
* @generated
* @ordered
*/
protected EMap<String, String> persistedState;
/**
* The cached value of the '{@link #getTags() <em>Tags</em>}' attribute list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTags()
* @generated
* @ordered
*/
protected EList<String> tags;
/**
* The default value of the '{@link #getContributorURI() <em>Contributor URI</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getContributorURI()
* @generated
* @ordered
*/
protected static final String CONTRIBUTOR_URI_EDEFAULT = null;
/**
* The cached value of the '{@link #getContributorURI() <em>Contributor URI</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getContributorURI()
* @generated
* @ordered
*/
protected String contributorURI = CONTRIBUTOR_URI_EDEFAULT;
/**
* The cached value of the '{@link #getTransientData() <em>Transient Data</em>}' map.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTransientData()
* @generated
* @ordered
*/
protected EMap<String, Object> transientData;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ApplicationElementImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ApplicationPackageImpl.Literals.APPLICATION_ELEMENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getElementId() {
return elementId;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setElementId(String newElementId) {
String oldElementId = elementId;
elementId = newElementId;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ApplicationPackageImpl.APPLICATION_ELEMENT__ELEMENT_ID, oldElementId, elementId));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Map<String, String> getPersistedState() {
if (persistedState == null) {
persistedState = new EcoreEMap<String,String>(ApplicationPackageImpl.Literals.STRING_TO_STRING_MAP, StringToStringMapImpl.class, this, ApplicationPackageImpl.APPLICATION_ELEMENT__PERSISTED_STATE);
}
return persistedState.map();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public List<String> getTags() {
if (tags == null) {
tags = new EDataTypeUniqueEList<String>(String.class, this, ApplicationPackageImpl.APPLICATION_ELEMENT__TAGS);
}
return tags;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getContributorURI() {
return contributorURI;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
public void setContributorURI(String newContributorURI) {
String oldContributorURI = contributorURI;
contributorURI = (newContributorURI == null) ? null : newContributorURI.intern();
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ApplicationPackageImpl.APPLICATION_ELEMENT__CONTRIBUTOR_URI, oldContributorURI, contributorURI));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Map<String, Object> getTransientData() {
if (transientData == null) {
transientData = new EcoreEMap<String,Object>(ApplicationPackageImpl.Literals.STRING_TO_OBJECT_MAP, StringToObjectMapImpl.class, this, ApplicationPackageImpl.APPLICATION_ELEMENT__TRANSIENT_DATA);
}
return transientData.map();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ApplicationPackageImpl.APPLICATION_ELEMENT__PERSISTED_STATE:
return ((InternalEList<?>)((EMap.InternalMapView<String, String>)getPersistedState()).eMap()).basicRemove(otherEnd, msgs);
case ApplicationPackageImpl.APPLICATION_ELEMENT__TRANSIENT_DATA:
return ((InternalEList<?>)((EMap.InternalMapView<String, Object>)getTransientData()).eMap()).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 ApplicationPackageImpl.APPLICATION_ELEMENT__ELEMENT_ID:
return getElementId();
case ApplicationPackageImpl.APPLICATION_ELEMENT__PERSISTED_STATE:
if (coreType) return ((EMap.InternalMapView<String, String>)getPersistedState()).eMap();
else return getPersistedState();
case ApplicationPackageImpl.APPLICATION_ELEMENT__TAGS:
return getTags();
case ApplicationPackageImpl.APPLICATION_ELEMENT__CONTRIBUTOR_URI:
return getContributorURI();
case ApplicationPackageImpl.APPLICATION_ELEMENT__TRANSIENT_DATA:
if (coreType) return ((EMap.InternalMapView<String, Object>)getTransientData()).eMap();
else return getTransientData();
}
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 ApplicationPackageImpl.APPLICATION_ELEMENT__ELEMENT_ID:
setElementId((String)newValue);
return;
case ApplicationPackageImpl.APPLICATION_ELEMENT__PERSISTED_STATE:
((EStructuralFeature.Setting)((EMap.InternalMapView<String, String>)getPersistedState()).eMap()).set(newValue);
return;
case ApplicationPackageImpl.APPLICATION_ELEMENT__TAGS:
getTags().clear();
getTags().addAll((Collection<? extends String>)newValue);
return;
case ApplicationPackageImpl.APPLICATION_ELEMENT__CONTRIBUTOR_URI:
setContributorURI((String)newValue);
return;
case ApplicationPackageImpl.APPLICATION_ELEMENT__TRANSIENT_DATA:
((EStructuralFeature.Setting)((EMap.InternalMapView<String, Object>)getTransientData()).eMap()).set(newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ApplicationPackageImpl.APPLICATION_ELEMENT__ELEMENT_ID:
setElementId(ELEMENT_ID_EDEFAULT);
return;
case ApplicationPackageImpl.APPLICATION_ELEMENT__PERSISTED_STATE:
getPersistedState().clear();
return;
case ApplicationPackageImpl.APPLICATION_ELEMENT__TAGS:
getTags().clear();
return;
case ApplicationPackageImpl.APPLICATION_ELEMENT__CONTRIBUTOR_URI:
setContributorURI(CONTRIBUTOR_URI_EDEFAULT);
return;
case ApplicationPackageImpl.APPLICATION_ELEMENT__TRANSIENT_DATA:
getTransientData().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ApplicationPackageImpl.APPLICATION_ELEMENT__ELEMENT_ID:
return ELEMENT_ID_EDEFAULT == null ? elementId != null : !ELEMENT_ID_EDEFAULT.equals(elementId);
case ApplicationPackageImpl.APPLICATION_ELEMENT__PERSISTED_STATE:
return persistedState != null && !persistedState.isEmpty();
case ApplicationPackageImpl.APPLICATION_ELEMENT__TAGS:
return tags != null && !tags.isEmpty();
case ApplicationPackageImpl.APPLICATION_ELEMENT__CONTRIBUTOR_URI:
return CONTRIBUTOR_URI_EDEFAULT == null ? contributorURI != null : !CONTRIBUTOR_URI_EDEFAULT.equals(contributorURI);
case ApplicationPackageImpl.APPLICATION_ELEMENT__TRANSIENT_DATA:
return transientData != null && !transientData.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private String toStringGen() {
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (elementId: "); //$NON-NLS-1$
result.append(elementId);
result.append(", tags: "); //$NON-NLS-1$
result.append(tags);
result.append(", contributorURI: "); //$NON-NLS-1$
result.append(contributorURI);
result.append(')');
return result.toString();
}
public String toString() {
String result = toStringGen();
if (elementId != null) {
result = elementId + "=" + result.replace(" (elementId: " + elementId + ", ", " (");
}
return result.toString();
}
} //ApplicationElementImpl