| /******************************************************************************* |
| * Copyright (c) 2009, 2019 Xored Software Inc 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 |
| * https://www.eclipse.org/legal/epl-v20.html |
| * |
| * Contributors: |
| * Xored Software Inc - initial API and implementation and/or initial documentation |
| *******************************************************************************/ |
| package org.eclipse.rcptt.ecl.data.commands.impl; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.ecore.InternalEObject; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
| import org.eclipse.rcptt.ecl.core.impl.CommandImpl; |
| import org.eclipse.rcptt.ecl.data.commands.Append; |
| import org.eclipse.rcptt.ecl.data.commands.CommandsPackage; |
| import org.eclipse.rcptt.ecl.data.objects.Tree; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Append</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.rcptt.ecl.data.commands.impl.AppendImpl#getObject <em>Object</em>}</li> |
| * <li>{@link org.eclipse.rcptt.ecl.data.commands.impl.AppendImpl#getChildren <em>Children</em>}</li> |
| * <li>{@link org.eclipse.rcptt.ecl.data.commands.impl.AppendImpl#getIndex <em>Index</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class AppendImpl extends CommandImpl implements Append { |
| /** |
| * The cached value of the '{@link #getObject() <em>Object</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getObject() |
| * @generated |
| * @ordered |
| */ |
| protected EObject object; |
| |
| /** |
| * The cached value of the '{@link #getChildren() <em>Children</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getChildren() |
| * @generated |
| * @ordered |
| */ |
| protected EList<EObject> children; |
| |
| /** |
| * The default value of the '{@link #getIndex() <em>Index</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIndex() |
| * @generated |
| * @ordered |
| */ |
| protected static final int INDEX_EDEFAULT = -1; |
| |
| /** |
| * The cached value of the '{@link #getIndex() <em>Index</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIndex() |
| * @generated |
| * @ordered |
| */ |
| protected int index = INDEX_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected AppendImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return CommandsPackage.Literals.APPEND; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EObject getObject() { |
| if (object != null && object.eIsProxy()) { |
| InternalEObject oldObject = (InternalEObject)object; |
| object = eResolveProxy(oldObject); |
| if (object != oldObject) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, CommandsPackage.APPEND__OBJECT, oldObject, object)); |
| } |
| } |
| return object; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EObject basicGetObject() { |
| return object; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setObject(EObject newObject) { |
| EObject oldObject = object; |
| object = newObject; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, CommandsPackage.APPEND__OBJECT, oldObject, object)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<EObject> getChildren() { |
| if (children == null) { |
| children = new EObjectResolvingEList<EObject>(EObject.class, this, CommandsPackage.APPEND__CHILDREN); |
| } |
| return children; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public int getIndex() { |
| return index; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setIndex(int newIndex) { |
| int oldIndex = index; |
| index = newIndex; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, CommandsPackage.APPEND__INDEX, oldIndex, index)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case CommandsPackage.APPEND__OBJECT: |
| if (resolve) return getObject(); |
| return basicGetObject(); |
| case CommandsPackage.APPEND__CHILDREN: |
| return getChildren(); |
| case CommandsPackage.APPEND__INDEX: |
| return getIndex(); |
| } |
| 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 CommandsPackage.APPEND__OBJECT: |
| setObject((EObject)newValue); |
| return; |
| case CommandsPackage.APPEND__CHILDREN: |
| getChildren().clear(); |
| getChildren().addAll((Collection<? extends EObject>)newValue); |
| return; |
| case CommandsPackage.APPEND__INDEX: |
| setIndex((Integer)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case CommandsPackage.APPEND__OBJECT: |
| setObject((EObject)null); |
| return; |
| case CommandsPackage.APPEND__CHILDREN: |
| getChildren().clear(); |
| return; |
| case CommandsPackage.APPEND__INDEX: |
| setIndex(INDEX_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case CommandsPackage.APPEND__OBJECT: |
| return object != null; |
| case CommandsPackage.APPEND__CHILDREN: |
| return children != null && !children.isEmpty(); |
| case CommandsPackage.APPEND__INDEX: |
| return index != INDEX_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(" (index: "); |
| result.append(index); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //AppendImpl |