| /* |
| * Copyright (c) 2013, 2015 Eike Stepper (Berlin, Germany) 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: |
| * Eike Stepper - initial API and implementation |
| */ |
| package org.eclipse.emf.cdo.tests.model1.legacy.impl; |
| |
| import org.eclipse.emf.cdo.tests.model1.PurchaseOrder; |
| import org.eclipse.emf.cdo.tests.model1.Supplier; |
| import org.eclipse.emf.cdo.tests.model1.legacy.Model1Package; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.InternalEObject; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| |
| import java.util.Date; |
| |
| /** |
| * @author Eike Stepper |
| */ |
| public class PurchaseOrderImpl extends OrderImpl implements PurchaseOrder |
| { |
| /** |
| * The default value of the '{@link #getDate() <em>Date</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc |
| * --> |
| * |
| * @see #getDate() |
| * @generated |
| * @ordered |
| */ |
| protected static final Date DATE_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getDate() <em>Date</em>}' attribute. |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @see #getDate() |
| * @generated |
| * @ordered |
| */ |
| protected Date date = DATE_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getSupplier() <em>Supplier</em>}' reference. |
| * <!-- begin-user-doc --> <!-- |
| * end-user-doc --> |
| * @see #getSupplier() |
| * @generated |
| * @ordered |
| */ |
| protected Supplier supplier; |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| protected PurchaseOrderImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return Model1Package.eINSTANCE.getPurchaseOrder(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public Date getDate() |
| { |
| return date; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setDate(Date newDate) |
| { |
| Date oldDate = date; |
| date = newDate; |
| if (eNotificationRequired()) |
| { |
| eNotify(new ENotificationImpl(this, Notification.SET, Model1Package.PURCHASE_ORDER__DATE, oldDate, date)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public Supplier getSupplier() |
| { |
| if (supplier != null && supplier.eIsProxy()) |
| { |
| InternalEObject oldSupplier = (InternalEObject)supplier; |
| supplier = (Supplier)eResolveProxy(oldSupplier); |
| if (supplier != oldSupplier) |
| { |
| if (eNotificationRequired()) |
| { |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, Model1Package.PURCHASE_ORDER__SUPPLIER, oldSupplier, |
| supplier)); |
| } |
| } |
| } |
| return supplier; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public Supplier basicGetSupplier() |
| { |
| return supplier; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetSupplier(Supplier newSupplier, NotificationChain msgs) |
| { |
| Supplier oldSupplier = supplier; |
| supplier = newSupplier; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, |
| Model1Package.PURCHASE_ORDER__SUPPLIER, oldSupplier, newSupplier); |
| if (msgs == null) |
| { |
| msgs = notification; |
| } |
| else |
| { |
| msgs.add(notification); |
| } |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setSupplier(Supplier newSupplier) |
| { |
| if (newSupplier != supplier) |
| { |
| NotificationChain msgs = null; |
| if (supplier != null) |
| { |
| msgs = ((InternalEObject)supplier).eInverseRemove(this, Model1Package.SUPPLIER__PURCHASE_ORDERS, Supplier.class, |
| msgs); |
| } |
| if (newSupplier != null) |
| { |
| msgs = ((InternalEObject)newSupplier).eInverseAdd(this, Model1Package.SUPPLIER__PURCHASE_ORDERS, Supplier.class, |
| msgs); |
| } |
| msgs = basicSetSupplier(newSupplier, msgs); |
| if (msgs != null) |
| { |
| msgs.dispatch(); |
| } |
| } |
| else if (eNotificationRequired()) |
| { |
| eNotify(new ENotificationImpl(this, Notification.SET, Model1Package.PURCHASE_ORDER__SUPPLIER, newSupplier, |
| newSupplier)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case Model1Package.PURCHASE_ORDER__SUPPLIER: |
| if (supplier != null) |
| { |
| msgs = ((InternalEObject)supplier).eInverseRemove(this, Model1Package.SUPPLIER__PURCHASE_ORDERS, Supplier.class, |
| msgs); |
| } |
| return basicSetSupplier((Supplier)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 Model1Package.PURCHASE_ORDER__SUPPLIER: |
| return basicSetSupplier(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 Model1Package.PURCHASE_ORDER__DATE: |
| return getDate(); |
| case Model1Package.PURCHASE_ORDER__SUPPLIER: |
| if (resolve) |
| { |
| return getSupplier(); |
| } |
| return basicGetSupplier(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) |
| { |
| switch (featureID) |
| { |
| case Model1Package.PURCHASE_ORDER__DATE: |
| setDate((Date)newValue); |
| return; |
| case Model1Package.PURCHASE_ORDER__SUPPLIER: |
| setSupplier((Supplier)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case Model1Package.PURCHASE_ORDER__DATE: |
| setDate(DATE_EDEFAULT); |
| return; |
| case Model1Package.PURCHASE_ORDER__SUPPLIER: |
| setSupplier((Supplier)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case Model1Package.PURCHASE_ORDER__DATE: |
| return DATE_EDEFAULT == null ? date != null : !DATE_EDEFAULT.equals(date); |
| case Model1Package.PURCHASE_ORDER__SUPPLIER: |
| return supplier != null; |
| } |
| 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(" (date: "); |
| result.append(date); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } // PurchaseOrderImpl |