| /** |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * 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 |
| * |
| * Based on ideas from Xtext, Xtend, Xcore |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - Initial implementation |
| * |
| */ |
| package org.eclipse.osbp.xtext.entitymock.impl; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.InternalEObject; |
| |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| |
| import org.eclipse.osbp.dsl.semantic.entity.LEntityReference; |
| |
| import org.eclipse.osbp.xtext.entitymock.EntityMockAttributeByReference; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockDSLPackage; |
| import org.eclipse.osbp.xtext.entitymock.EntityMockEntity; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Entity Mock Attribute By Reference</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.osbp.xtext.entitymock.impl.EntityMockAttributeByReferenceImpl#getAttributeRef <em>Attribute Ref</em>}</li> |
| * <li>{@link org.eclipse.osbp.xtext.entitymock.impl.EntityMockAttributeByReferenceImpl#getMockedEntity <em>Mocked Entity</em>}</li> |
| * <li>{@link org.eclipse.osbp.xtext.entitymock.impl.EntityMockAttributeByReferenceImpl#getOptionalFor <em>Optional For</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class EntityMockAttributeByReferenceImpl extends IEntityMockAttributeImpl implements EntityMockAttributeByReference { |
| /** |
| * The cached value of the '{@link #getAttributeRef() <em>Attribute Ref</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getAttributeRef() |
| * @generated |
| * @ordered |
| */ |
| protected LEntityReference attributeRef; |
| |
| /** |
| * The cached value of the '{@link #getMockedEntity() <em>Mocked Entity</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getMockedEntity() |
| * @generated |
| * @ordered |
| */ |
| protected EntityMockEntity mockedEntity; |
| |
| /** |
| * The default value of the '{@link #getOptionalFor() <em>Optional For</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOptionalFor() |
| * @generated |
| * @ordered |
| */ |
| protected static final int OPTIONAL_FOR_EDEFAULT = 0; |
| |
| /** |
| * The cached value of the '{@link #getOptionalFor() <em>Optional For</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOptionalFor() |
| * @generated |
| * @ordered |
| */ |
| protected int optionalFor = OPTIONAL_FOR_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected EntityMockAttributeByReferenceImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return EntityMockDSLPackage.Literals.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public LEntityReference getAttributeRef() { |
| if (attributeRef != null && attributeRef.eIsProxy()) { |
| InternalEObject oldAttributeRef = (InternalEObject)attributeRef; |
| attributeRef = (LEntityReference)eResolveProxy(oldAttributeRef); |
| if (attributeRef != oldAttributeRef) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__ATTRIBUTE_REF, oldAttributeRef, attributeRef)); |
| } |
| } |
| return attributeRef; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public LEntityReference basicGetAttributeRef() { |
| return attributeRef; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setAttributeRef(LEntityReference newAttributeRef) { |
| LEntityReference oldAttributeRef = attributeRef; |
| attributeRef = newAttributeRef; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__ATTRIBUTE_REF, oldAttributeRef, attributeRef)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EntityMockEntity getMockedEntity() { |
| if (mockedEntity != null && mockedEntity.eIsProxy()) { |
| InternalEObject oldMockedEntity = (InternalEObject)mockedEntity; |
| mockedEntity = (EntityMockEntity)eResolveProxy(oldMockedEntity); |
| if (mockedEntity != oldMockedEntity) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__MOCKED_ENTITY, oldMockedEntity, mockedEntity)); |
| } |
| } |
| return mockedEntity; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EntityMockEntity basicGetMockedEntity() { |
| return mockedEntity; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setMockedEntity(EntityMockEntity newMockedEntity) { |
| EntityMockEntity oldMockedEntity = mockedEntity; |
| mockedEntity = newMockedEntity; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__MOCKED_ENTITY, oldMockedEntity, mockedEntity)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public int getOptionalFor() { |
| return optionalFor; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setOptionalFor(int newOptionalFor) { |
| int oldOptionalFor = optionalFor; |
| optionalFor = newOptionalFor; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__OPTIONAL_FOR, oldOptionalFor, optionalFor)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__ATTRIBUTE_REF: |
| if (resolve) return getAttributeRef(); |
| return basicGetAttributeRef(); |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__MOCKED_ENTITY: |
| if (resolve) return getMockedEntity(); |
| return basicGetMockedEntity(); |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__OPTIONAL_FOR: |
| return getOptionalFor(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__ATTRIBUTE_REF: |
| setAttributeRef((LEntityReference)newValue); |
| return; |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__MOCKED_ENTITY: |
| setMockedEntity((EntityMockEntity)newValue); |
| return; |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__OPTIONAL_FOR: |
| setOptionalFor((Integer)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__ATTRIBUTE_REF: |
| setAttributeRef((LEntityReference)null); |
| return; |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__MOCKED_ENTITY: |
| setMockedEntity((EntityMockEntity)null); |
| return; |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__OPTIONAL_FOR: |
| setOptionalFor(OPTIONAL_FOR_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__ATTRIBUTE_REF: |
| return attributeRef != null; |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__MOCKED_ENTITY: |
| return mockedEntity != null; |
| case EntityMockDSLPackage.ENTITY_MOCK_ATTRIBUTE_BY_REFERENCE__OPTIONAL_FOR: |
| return optionalFor != OPTIONAL_FOR_EDEFAULT; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (optionalFor: "); |
| result.append(optionalFor); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //EntityMockAttributeByReferenceImpl |