| /******************************************************************************* |
| * Copyright (c) 2013 RCP Vision (http://www.rcp-vision.com) 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 |
| *******************************************************************************/ |
| /** |
| */ |
| package org.eclipse.emf.parsley.examples.mail.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.EObjectContainmentEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.emf.parsley.examples.mail.Account; |
| import org.eclipse.emf.parsley.examples.mail.Folder; |
| import org.eclipse.emf.parsley.examples.mail.MailPackage; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Account</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.emf.parsley.examples.mail.impl.AccountImpl#getName <em>Name</em>}</li> |
| * <li>{@link org.eclipse.emf.parsley.examples.mail.impl.AccountImpl#getEmail <em>Email</em>}</li> |
| * <li>{@link org.eclipse.emf.parsley.examples.mail.impl.AccountImpl#getFolders <em>Folders</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class AccountImpl extends EObjectImpl implements Account { |
| /** |
| * 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 default value of the '{@link #getEmail() <em>Email</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getEmail() |
| * @generated |
| * @ordered |
| */ |
| protected static final String EMAIL_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getEmail() <em>Email</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getEmail() |
| * @generated |
| * @ordered |
| */ |
| protected String email = EMAIL_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getFolders() <em>Folders</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getFolders() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Folder> folders; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected AccountImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return MailPackage.Literals.ACCOUNT; |
| } |
| |
| /** |
| * <!-- 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, MailPackage.ACCOUNT__NAME, oldName, name)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getEmail() { |
| return email; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setEmail(String newEmail) { |
| String oldEmail = email; |
| email = newEmail; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MailPackage.ACCOUNT__EMAIL, oldEmail, email)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Folder> getFolders() { |
| if (folders == null) { |
| folders = new EObjectContainmentEList<Folder>(Folder.class, this, MailPackage.ACCOUNT__FOLDERS); |
| } |
| return folders; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case MailPackage.ACCOUNT__FOLDERS: |
| return ((InternalEList<?>)getFolders()).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 MailPackage.ACCOUNT__NAME: |
| return getName(); |
| case MailPackage.ACCOUNT__EMAIL: |
| return getEmail(); |
| case MailPackage.ACCOUNT__FOLDERS: |
| return getFolders(); |
| } |
| 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 MailPackage.ACCOUNT__NAME: |
| setName((String)newValue); |
| return; |
| case MailPackage.ACCOUNT__EMAIL: |
| setEmail((String)newValue); |
| return; |
| case MailPackage.ACCOUNT__FOLDERS: |
| getFolders().clear(); |
| getFolders().addAll((Collection<? extends Folder>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case MailPackage.ACCOUNT__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case MailPackage.ACCOUNT__EMAIL: |
| setEmail(EMAIL_EDEFAULT); |
| return; |
| case MailPackage.ACCOUNT__FOLDERS: |
| getFolders().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case MailPackage.ACCOUNT__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case MailPackage.ACCOUNT__EMAIL: |
| return EMAIL_EDEFAULT == null ? email != null : !EMAIL_EDEFAULT.equals(email); |
| case MailPackage.ACCOUNT__FOLDERS: |
| return folders != null && !folders.isEmpty(); |
| } |
| 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(" (name: "); |
| result.append(name); |
| result.append(", email: "); |
| result.append(email); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //AccountImpl |