| /** |
| * <copyright> |
| *******************************************************************************/ |
| package org.eclipse.ocl.examples.xtext.tests.noreflectioncompany.impl; |
| |
| import java.util.Collection; |
| import java.util.Map; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| import org.eclipse.emf.common.util.Diagnostic; |
| import org.eclipse.emf.common.util.DiagnosticChain; |
| import org.eclipse.emf.common.util.EList; |
| 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.impl.EObjectImpl; |
| import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.ocl.examples.xtext.tests.noreflectioncompany.Company; |
| import org.eclipse.ocl.examples.xtext.tests.noreflectioncompany.CompanySizeKind; |
| import org.eclipse.ocl.examples.xtext.tests.noreflectioncompany.Employee; |
| import org.eclipse.ocl.examples.xtext.tests.noreflectioncompany.NoreflectioncompanyPackage; |
| import org.eclipse.ocl.examples.xtext.tests.noreflectioncompany.util.NoreflectioncompanyValidator; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Company</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.examples.xtext.tests.noreflectioncompany.impl.CompanyImpl#getName <em>Name</em>}</li> |
| * <li>{@link org.eclipse.ocl.examples.xtext.tests.noreflectioncompany.impl.CompanyImpl#getEmployees <em>Employees</em>}</li> |
| * <li>{@link org.eclipse.ocl.examples.xtext.tests.noreflectioncompany.impl.CompanyImpl#getSize <em>Size</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class CompanyImpl extends EObjectImpl implements Company { |
| /** |
| * 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 #getEmployees() <em>Employees</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getEmployees() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Employee> employees; |
| |
| /** |
| * The cached setting delegate for the '{@link #getSize() <em>Size</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getSize() |
| * @generated |
| * @ordered |
| */ |
| protected EStructuralFeature.Internal.SettingDelegate SIZE__ESETTING_DELEGATE = ((EStructuralFeature.Internal)NoreflectioncompanyPackage.Literals.COMPANY__SIZE).getSettingDelegate(); |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected CompanyImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return NoreflectioncompanyPackage.Literals.COMPANY; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String getName() { |
| return name; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setName(String newName) { |
| String oldName = name; |
| name = newName; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, NoreflectioncompanyPackage.COMPANY__NAME, oldName, name)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<Employee> getEmployees() { |
| if (employees == null) { |
| employees = new EObjectContainmentWithInverseEList<Employee>(Employee.class, this, NoreflectioncompanyPackage.COMPANY__EMPLOYEES, NoreflectioncompanyPackage.EMPLOYEE__COMPANY); |
| } |
| return employees; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public CompanySizeKind getSize() { |
| return (CompanySizeKind)SIZE__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); |
| } |
| |
| /** |
| * The cached validation expression for the '{@link #dummyInvariant(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Dummy Invariant</em>}' invariant operation. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #dummyInvariant(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| * @generated |
| * @ordered |
| */ |
| protected static final String DUMMY_INVARIANT_DIAGNOSTIC_CHAIN_MAP__EEXPRESSION = "true"; //$NON-NLS-1$ |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean dummyInvariant(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| return |
| NoreflectioncompanyValidator.validate |
| (NoreflectioncompanyPackage.Literals.COMPANY, |
| this, |
| diagnostics, |
| context, |
| "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", //$NON-NLS-1$ |
| NoreflectioncompanyPackage.Literals.COMPANY.getEOperations().get(0), |
| DUMMY_INVARIANT_DIAGNOSTIC_CHAIN_MAP__EEXPRESSION, |
| Diagnostic.ERROR, |
| NoreflectioncompanyValidator.DIAGNOSTIC_SOURCE, |
| NoreflectioncompanyValidator.COMPANY__DUMMY_INVARIANT); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case NoreflectioncompanyPackage.COMPANY__EMPLOYEES: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getEmployees()).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 NoreflectioncompanyPackage.COMPANY__EMPLOYEES: |
| return ((InternalEList<?>)getEmployees()).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 NoreflectioncompanyPackage.COMPANY__NAME: |
| return getName(); |
| case NoreflectioncompanyPackage.COMPANY__EMPLOYEES: |
| return getEmployees(); |
| case NoreflectioncompanyPackage.COMPANY__SIZE: |
| return getSize(); |
| } |
| 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 NoreflectioncompanyPackage.COMPANY__NAME: |
| setName((String)newValue); |
| return; |
| case NoreflectioncompanyPackage.COMPANY__EMPLOYEES: |
| getEmployees().clear(); |
| getEmployees().addAll((Collection<? extends Employee>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case NoreflectioncompanyPackage.COMPANY__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case NoreflectioncompanyPackage.COMPANY__EMPLOYEES: |
| getEmployees().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case NoreflectioncompanyPackage.COMPANY__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case NoreflectioncompanyPackage.COMPANY__EMPLOYEES: |
| return employees != null && !employees.isEmpty(); |
| case NoreflectioncompanyPackage.COMPANY__SIZE: |
| return SIZE__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuilder result = new StringBuilder(super.toString()); |
| result.append(" (name: "); //$NON-NLS-1$ |
| result.append(name); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //CompanyImpl |