blob: 55d1091b182f72969f4f96f1b764ab1d18e8007e [file] [log] [blame]
/*******************************************************************************
* 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 v2.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.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.rcptt.ecl.core.EclMap;
import org.eclipse.rcptt.ecl.core.impl.CommandImpl;
import org.eclipse.rcptt.ecl.data.commands.CommandsPackage;
import org.eclipse.rcptt.ecl.data.commands.TreeNode;
import org.eclipse.rcptt.ecl.data.objects.Attribute;
import org.eclipse.rcptt.ecl.data.objects.Tree;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Tree Node</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.rcptt.ecl.data.commands.impl.TreeNodeImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.rcptt.ecl.data.commands.impl.TreeNodeImpl#getAttrs <em>Attrs</em>}</li>
* <li>{@link org.eclipse.rcptt.ecl.data.commands.impl.TreeNodeImpl#getChildren <em>Children</em>}</li>
* <li>{@link org.eclipse.rcptt.ecl.data.commands.impl.TreeNodeImpl#getText <em>Text</em>}</li>
* </ul>
*
* @generated
*/
public class TreeNodeImpl extends CommandImpl implements TreeNode {
/**
* 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 #getAttrs() <em>Attrs</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAttrs()
* @generated
* @ordered
*/
protected EclMap attrs;
/**
* The cached value of the '{@link #getChildren() <em>Children</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getChildren()
* @generated
* @ordered
*/
protected EList<Tree> children;
/**
* The default value of the '{@link #getText() <em>Text</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getText()
* @generated
* @ordered
*/
protected static final String TEXT_EDEFAULT = null;
/**
* The cached value of the '{@link #getText() <em>Text</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getText()
* @generated
* @ordered
*/
protected String text = TEXT_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TreeNodeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CommandsPackage.Literals.TREE_NODE;
}
/**
* <!-- 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, CommandsPackage.TREE_NODE__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EclMap getAttrs() {
if (attrs != null && attrs.eIsProxy()) {
InternalEObject oldAttrs = (InternalEObject)attrs;
attrs = (EclMap)eResolveProxy(oldAttrs);
if (attrs != oldAttrs) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, CommandsPackage.TREE_NODE__ATTRS, oldAttrs, attrs));
}
}
return attrs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EclMap basicGetAttrs() {
return attrs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAttrs(EclMap newAttrs) {
EclMap oldAttrs = attrs;
attrs = newAttrs;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CommandsPackage.TREE_NODE__ATTRS, oldAttrs, attrs));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Tree> getChildren() {
if (children == null) {
children = new EObjectResolvingEList<Tree>(Tree.class, this, CommandsPackage.TREE_NODE__CHILDREN);
}
return children;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getText() {
return text;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setText(String newText) {
String oldText = text;
text = newText;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CommandsPackage.TREE_NODE__TEXT, oldText, text));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case CommandsPackage.TREE_NODE__NAME:
return getName();
case CommandsPackage.TREE_NODE__ATTRS:
if (resolve) return getAttrs();
return basicGetAttrs();
case CommandsPackage.TREE_NODE__CHILDREN:
return getChildren();
case CommandsPackage.TREE_NODE__TEXT:
return getText();
}
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.TREE_NODE__NAME:
setName((String)newValue);
return;
case CommandsPackage.TREE_NODE__ATTRS:
setAttrs((EclMap)newValue);
return;
case CommandsPackage.TREE_NODE__CHILDREN:
getChildren().clear();
getChildren().addAll((Collection<? extends Tree>)newValue);
return;
case CommandsPackage.TREE_NODE__TEXT:
setText((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CommandsPackage.TREE_NODE__NAME:
setName(NAME_EDEFAULT);
return;
case CommandsPackage.TREE_NODE__ATTRS:
setAttrs((EclMap)null);
return;
case CommandsPackage.TREE_NODE__CHILDREN:
getChildren().clear();
return;
case CommandsPackage.TREE_NODE__TEXT:
setText(TEXT_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CommandsPackage.TREE_NODE__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case CommandsPackage.TREE_NODE__ATTRS:
return attrs != null;
case CommandsPackage.TREE_NODE__CHILDREN:
return children != null && !children.isEmpty();
case CommandsPackage.TREE_NODE__TEXT:
return TEXT_EDEFAULT == null ? text != null : !TEXT_EDEFAULT.equals(text);
}
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(", text: ");
result.append(text);
result.append(')');
return result.toString();
}
} //TreeNodeImpl