| /******************************************************************************* |
| * Copyright (c) 2012-2014 SAP SE. |
| * 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: |
| * SAP SE - initial API and implementation and/or initial documentation |
| * |
| *******************************************************************************/ |
| /** |
| */ |
| package org.eclipse.ogee.model.odata.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.EObjectImpl; |
| import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.ogee.model.odata.Annotation; |
| import org.eclipse.ogee.model.odata.Documentation; |
| import org.eclipse.ogee.model.odata.IDocumentable; |
| import org.eclipse.ogee.model.odata.IPropertyTypeUsage; |
| import org.eclipse.ogee.model.odata.OdataPackage; |
| import org.eclipse.ogee.model.odata.ValueAnnotation; |
| import org.eclipse.ogee.model.odata.ValueTerm; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Value Term</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.ValueTermImpl#getAnnotations <em>Annotations</em>}</li> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.ValueTermImpl#getDocumentation <em>Documentation</em>}</li> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.ValueTermImpl#getName <em>Name</em>}</li> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.ValueTermImpl#getType <em>Type</em>}</li> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.ValueTermImpl#getValueAnnotations <em>Value Annotations</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class ValueTermImpl extends EObjectImpl implements ValueTerm { |
| /** |
| * The cached value of the '{@link #getAnnotations() <em>Annotations</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getAnnotations() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Annotation> annotations; |
| |
| /** |
| * The cached value of the '{@link #getDocumentation() <em>Documentation</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getDocumentation() |
| * @generated |
| * @ordered |
| */ |
| protected Documentation documentation; |
| |
| /** |
| * The default value of the '{@link #getName() <em>Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getName() |
| * @generated |
| * @ordered |
| */ |
| protected static final String NAME_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getName() <em>Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getName() |
| * @generated |
| * @ordered |
| */ |
| protected String name = NAME_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getType() <em>Type</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getType() |
| * @generated |
| * @ordered |
| */ |
| protected IPropertyTypeUsage type; |
| |
| /** |
| * The cached value of the '{@link #getValueAnnotations() <em>Value Annotations</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getValueAnnotations() |
| * @generated |
| * @ordered |
| */ |
| protected EList<ValueAnnotation> valueAnnotations; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ValueTermImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return OdataPackage.Literals.VALUE_TERM; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Annotation> getAnnotations() { |
| if (annotations == null) { |
| annotations = new EObjectWithInverseResolvingEList<Annotation>(Annotation.class, this, OdataPackage.VALUE_TERM__ANNOTATIONS, OdataPackage.ANNOTATION__TARGET); |
| } |
| return annotations; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Documentation getDocumentation() { |
| return documentation; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetDocumentation(Documentation newDocumentation, NotificationChain msgs) { |
| Documentation oldDocumentation = documentation; |
| documentation = newDocumentation; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OdataPackage.VALUE_TERM__DOCUMENTATION, oldDocumentation, newDocumentation); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setDocumentation(Documentation newDocumentation) { |
| if (newDocumentation != documentation) { |
| NotificationChain msgs = null; |
| if (documentation != null) |
| msgs = ((InternalEObject)documentation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OdataPackage.VALUE_TERM__DOCUMENTATION, null, msgs); |
| if (newDocumentation != null) |
| msgs = ((InternalEObject)newDocumentation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OdataPackage.VALUE_TERM__DOCUMENTATION, null, msgs); |
| msgs = basicSetDocumentation(newDocumentation, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OdataPackage.VALUE_TERM__DOCUMENTATION, newDocumentation, newDocumentation)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getName() { |
| return name; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setName(String newName) { |
| String oldName = name; |
| name = newName; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OdataPackage.VALUE_TERM__NAME, oldName, name)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public IPropertyTypeUsage getType() { |
| return type; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetType(IPropertyTypeUsage newType, NotificationChain msgs) { |
| IPropertyTypeUsage oldType = type; |
| type = newType; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OdataPackage.VALUE_TERM__TYPE, oldType, newType); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setType(IPropertyTypeUsage newType) { |
| if (newType != type) { |
| NotificationChain msgs = null; |
| if (type != null) |
| msgs = ((InternalEObject)type).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OdataPackage.VALUE_TERM__TYPE, null, msgs); |
| if (newType != null) |
| msgs = ((InternalEObject)newType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OdataPackage.VALUE_TERM__TYPE, null, msgs); |
| msgs = basicSetType(newType, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OdataPackage.VALUE_TERM__TYPE, newType, newType)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<ValueAnnotation> getValueAnnotations() { |
| if (valueAnnotations == null) { |
| valueAnnotations = new EObjectWithInverseResolvingEList<ValueAnnotation>(ValueAnnotation.class, this, OdataPackage.VALUE_TERM__VALUE_ANNOTATIONS, OdataPackage.VALUE_ANNOTATION__TERM); |
| } |
| return valueAnnotations; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case OdataPackage.VALUE_TERM__ANNOTATIONS: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getAnnotations()).basicAdd(otherEnd, msgs); |
| case OdataPackage.VALUE_TERM__VALUE_ANNOTATIONS: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getValueAnnotations()).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 OdataPackage.VALUE_TERM__ANNOTATIONS: |
| return ((InternalEList<?>)getAnnotations()).basicRemove(otherEnd, msgs); |
| case OdataPackage.VALUE_TERM__DOCUMENTATION: |
| return basicSetDocumentation(null, msgs); |
| case OdataPackage.VALUE_TERM__TYPE: |
| return basicSetType(null, msgs); |
| case OdataPackage.VALUE_TERM__VALUE_ANNOTATIONS: |
| return ((InternalEList<?>)getValueAnnotations()).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 OdataPackage.VALUE_TERM__ANNOTATIONS: |
| return getAnnotations(); |
| case OdataPackage.VALUE_TERM__DOCUMENTATION: |
| return getDocumentation(); |
| case OdataPackage.VALUE_TERM__NAME: |
| return getName(); |
| case OdataPackage.VALUE_TERM__TYPE: |
| return getType(); |
| case OdataPackage.VALUE_TERM__VALUE_ANNOTATIONS: |
| return getValueAnnotations(); |
| } |
| 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 OdataPackage.VALUE_TERM__ANNOTATIONS: |
| getAnnotations().clear(); |
| getAnnotations().addAll((Collection<? extends Annotation>)newValue); |
| return; |
| case OdataPackage.VALUE_TERM__DOCUMENTATION: |
| setDocumentation((Documentation)newValue); |
| return; |
| case OdataPackage.VALUE_TERM__NAME: |
| setName((String)newValue); |
| return; |
| case OdataPackage.VALUE_TERM__TYPE: |
| setType((IPropertyTypeUsage)newValue); |
| return; |
| case OdataPackage.VALUE_TERM__VALUE_ANNOTATIONS: |
| getValueAnnotations().clear(); |
| getValueAnnotations().addAll((Collection<? extends ValueAnnotation>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case OdataPackage.VALUE_TERM__ANNOTATIONS: |
| getAnnotations().clear(); |
| return; |
| case OdataPackage.VALUE_TERM__DOCUMENTATION: |
| setDocumentation((Documentation)null); |
| return; |
| case OdataPackage.VALUE_TERM__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case OdataPackage.VALUE_TERM__TYPE: |
| setType((IPropertyTypeUsage)null); |
| return; |
| case OdataPackage.VALUE_TERM__VALUE_ANNOTATIONS: |
| getValueAnnotations().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case OdataPackage.VALUE_TERM__ANNOTATIONS: |
| return annotations != null && !annotations.isEmpty(); |
| case OdataPackage.VALUE_TERM__DOCUMENTATION: |
| return documentation != null; |
| case OdataPackage.VALUE_TERM__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case OdataPackage.VALUE_TERM__TYPE: |
| return type != null; |
| case OdataPackage.VALUE_TERM__VALUE_ANNOTATIONS: |
| return valueAnnotations != null && !valueAnnotations.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| if (baseClass == IDocumentable.class) { |
| switch (derivedFeatureID) { |
| case OdataPackage.VALUE_TERM__DOCUMENTATION: return OdataPackage.IDOCUMENTABLE__DOCUMENTATION; |
| default: return -1; |
| } |
| } |
| return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { |
| if (baseClass == IDocumentable.class) { |
| switch (baseFeatureID) { |
| case OdataPackage.IDOCUMENTABLE__DOCUMENTATION: return OdataPackage.VALUE_TERM__DOCUMENTATION; |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (name: "); //$NON-NLS-1$ |
| result.append(name); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //ValueTermImpl |