| /******************************************************************************* |
| * 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.Property; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Property</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.PropertyImpl#getAnnotations <em>Annotations</em>}</li> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.PropertyImpl#getDocumentation <em>Documentation</em>}</li> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.PropertyImpl#getName <em>Name</em>}</li> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.PropertyImpl#getType <em>Type</em>}</li> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.PropertyImpl#isNullable <em>Nullable</em>}</li> |
| * <li>{@link org.eclipse.ogee.model.odata.impl.PropertyImpl#isForEtag <em>For Etag</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class PropertyImpl extends EObjectImpl implements Property { |
| /** |
| * 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 default value of the '{@link #isNullable() <em>Nullable</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isNullable() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean NULLABLE_EDEFAULT = false; |
| |
| /** |
| * The cached value of the '{@link #isNullable() <em>Nullable</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isNullable() |
| * @generated |
| * @ordered |
| */ |
| protected boolean nullable = NULLABLE_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #isForEtag() <em>For Etag</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isForEtag() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean FOR_ETAG_EDEFAULT = false; |
| |
| /** |
| * The cached value of the '{@link #isForEtag() <em>For Etag</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isForEtag() |
| * @generated |
| * @ordered |
| */ |
| protected boolean forEtag = FOR_ETAG_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected PropertyImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return OdataPackage.Literals.PROPERTY; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Annotation> getAnnotations() { |
| if (annotations == null) { |
| annotations = new EObjectWithInverseResolvingEList<Annotation>(Annotation.class, this, OdataPackage.PROPERTY__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.PROPERTY__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.PROPERTY__DOCUMENTATION, null, msgs); |
| if (newDocumentation != null) |
| msgs = ((InternalEObject)newDocumentation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OdataPackage.PROPERTY__DOCUMENTATION, null, msgs); |
| msgs = basicSetDocumentation(newDocumentation, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OdataPackage.PROPERTY__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.PROPERTY__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.PROPERTY__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.PROPERTY__TYPE, null, msgs); |
| if (newType != null) |
| msgs = ((InternalEObject)newType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OdataPackage.PROPERTY__TYPE, null, msgs); |
| msgs = basicSetType(newType, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OdataPackage.PROPERTY__TYPE, newType, newType)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isNullable() { |
| return nullable; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setNullable(boolean newNullable) { |
| boolean oldNullable = nullable; |
| nullable = newNullable; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OdataPackage.PROPERTY__NULLABLE, oldNullable, nullable)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isForEtag() { |
| return forEtag; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setForEtag(boolean newForEtag) { |
| boolean oldForEtag = forEtag; |
| forEtag = newForEtag; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OdataPackage.PROPERTY__FOR_ETAG, oldForEtag, forEtag)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case OdataPackage.PROPERTY__ANNOTATIONS: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getAnnotations()).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.PROPERTY__ANNOTATIONS: |
| return ((InternalEList<?>)getAnnotations()).basicRemove(otherEnd, msgs); |
| case OdataPackage.PROPERTY__DOCUMENTATION: |
| return basicSetDocumentation(null, msgs); |
| case OdataPackage.PROPERTY__TYPE: |
| return basicSetType(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 OdataPackage.PROPERTY__ANNOTATIONS: |
| return getAnnotations(); |
| case OdataPackage.PROPERTY__DOCUMENTATION: |
| return getDocumentation(); |
| case OdataPackage.PROPERTY__NAME: |
| return getName(); |
| case OdataPackage.PROPERTY__TYPE: |
| return getType(); |
| case OdataPackage.PROPERTY__NULLABLE: |
| return isNullable(); |
| case OdataPackage.PROPERTY__FOR_ETAG: |
| return isForEtag(); |
| } |
| 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.PROPERTY__ANNOTATIONS: |
| getAnnotations().clear(); |
| getAnnotations().addAll((Collection<? extends Annotation>)newValue); |
| return; |
| case OdataPackage.PROPERTY__DOCUMENTATION: |
| setDocumentation((Documentation)newValue); |
| return; |
| case OdataPackage.PROPERTY__NAME: |
| setName((String)newValue); |
| return; |
| case OdataPackage.PROPERTY__TYPE: |
| setType((IPropertyTypeUsage)newValue); |
| return; |
| case OdataPackage.PROPERTY__NULLABLE: |
| setNullable((Boolean)newValue); |
| return; |
| case OdataPackage.PROPERTY__FOR_ETAG: |
| setForEtag((Boolean)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case OdataPackage.PROPERTY__ANNOTATIONS: |
| getAnnotations().clear(); |
| return; |
| case OdataPackage.PROPERTY__DOCUMENTATION: |
| setDocumentation((Documentation)null); |
| return; |
| case OdataPackage.PROPERTY__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case OdataPackage.PROPERTY__TYPE: |
| setType((IPropertyTypeUsage)null); |
| return; |
| case OdataPackage.PROPERTY__NULLABLE: |
| setNullable(NULLABLE_EDEFAULT); |
| return; |
| case OdataPackage.PROPERTY__FOR_ETAG: |
| setForEtag(FOR_ETAG_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case OdataPackage.PROPERTY__ANNOTATIONS: |
| return annotations != null && !annotations.isEmpty(); |
| case OdataPackage.PROPERTY__DOCUMENTATION: |
| return documentation != null; |
| case OdataPackage.PROPERTY__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case OdataPackage.PROPERTY__TYPE: |
| return type != null; |
| case OdataPackage.PROPERTY__NULLABLE: |
| return nullable != NULLABLE_EDEFAULT; |
| case OdataPackage.PROPERTY__FOR_ETAG: |
| return forEtag != FOR_ETAG_EDEFAULT; |
| } |
| 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.PROPERTY__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.PROPERTY__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(", nullable: "); //$NON-NLS-1$ |
| result.append(nullable); |
| result.append(", forEtag: "); //$NON-NLS-1$ |
| result.append(forEtag); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //PropertyImpl |