| /* |
| * Copyright (c) 2014, 2015 Eike Stepper (Loehne, Germany) and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v20.html |
| * |
| * Contributors: |
| * Eike Stepper - initial API and implementation |
| */ |
| package org.eclipse.oomph.targlets.impl; |
| |
| import org.eclipse.oomph.base.impl.ModelElementImpl; |
| import org.eclipse.oomph.targlets.Targlet; |
| import org.eclipse.oomph.targlets.TargletContainer; |
| import org.eclipse.oomph.targlets.TargletPackage; |
| |
| 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.util.EObjectContainmentEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import java.util.Collection; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Container</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.oomph.targlets.impl.TargletContainerImpl#getID <em>ID</em>}</li> |
| * <li>{@link org.eclipse.oomph.targlets.impl.TargletContainerImpl#getTarglets <em>Targlets</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class TargletContainerImpl extends ModelElementImpl implements TargletContainer |
| { |
| /** |
| * The default value of the '{@link #getID() <em>ID</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getID() |
| * @generated |
| * @ordered |
| */ |
| protected static final String ID_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getID() <em>ID</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getID() |
| * @generated |
| * @ordered |
| */ |
| protected String iD = ID_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getTarglets() <em>Targlets</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTarglets() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Targlet> targlets; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected TargletContainerImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return TargletPackage.Literals.TARGLET_CONTAINER; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getID() |
| { |
| return iD; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setID(String newID) |
| { |
| String oldID = iD; |
| iD = newID; |
| if (eNotificationRequired()) |
| { |
| eNotify(new ENotificationImpl(this, Notification.SET, TargletPackage.TARGLET_CONTAINER__ID, oldID, iD)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Targlet> getTarglets() |
| { |
| if (targlets == null) |
| { |
| targlets = new EObjectContainmentEList<Targlet>(Targlet.class, this, TargletPackage.TARGLET_CONTAINER__TARGLETS); |
| } |
| return targlets; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case TargletPackage.TARGLET_CONTAINER__TARGLETS: |
| return ((InternalEList<?>)getTarglets()).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 TargletPackage.TARGLET_CONTAINER__ID: |
| return getID(); |
| case TargletPackage.TARGLET_CONTAINER__TARGLETS: |
| return getTarglets(); |
| } |
| 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 TargletPackage.TARGLET_CONTAINER__ID: |
| setID((String)newValue); |
| return; |
| case TargletPackage.TARGLET_CONTAINER__TARGLETS: |
| getTarglets().clear(); |
| getTarglets().addAll((Collection<? extends Targlet>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case TargletPackage.TARGLET_CONTAINER__ID: |
| setID(ID_EDEFAULT); |
| return; |
| case TargletPackage.TARGLET_CONTAINER__TARGLETS: |
| getTarglets().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case TargletPackage.TARGLET_CONTAINER__ID: |
| return ID_EDEFAULT == null ? iD != null : !ID_EDEFAULT.equals(iD); |
| case TargletPackage.TARGLET_CONTAINER__TARGLETS: |
| return targlets != null && !targlets.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(" (iD: "); |
| result.append(iD); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } // TargletContainerImpl |