/**
* Copyright (c) 2013 Puppet Labs, Inc. and other contributors, as listed below.
* 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
*
* Contributors:
* Puppet Labs
*/
package com.puppetlabs.geppetto.pp.impl;
import com.puppetlabs.geppetto.pp.AttributeOperation;
import com.puppetlabs.geppetto.pp.Expression;
import com.puppetlabs.geppetto.pp.PPPackage;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
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;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Attribute Operation</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link com.puppetlabs.geppetto.pp.impl.AttributeOperationImpl#getValue <em>Value</em>}</li>
* <li>{@link com.puppetlabs.geppetto.pp.impl.AttributeOperationImpl#getKey <em>Key</em>}</li>
* <li>{@link com.puppetlabs.geppetto.pp.impl.AttributeOperationImpl#getOp <em>Op</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class AttributeOperationImpl extends EObjectImpl implements AttributeOperation {
/**
* The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getValue()
* @generated
* @ordered
*/
protected Expression value;
/**
* The default value of the '{@link #getKey() <em>Key</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getKey()
* @generated
* @ordered
*/
protected static final String KEY_EDEFAULT = null;
/**
* The cached value of the '{@link #getKey() <em>Key</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getKey()
* @generated
* @ordered
*/
protected String key = KEY_EDEFAULT;
/**
* The default value of the '{@link #getOp() <em>Op</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getOp()
* @generated
* @ordered
*/
protected static final String OP_EDEFAULT = null;
/**
* The cached value of the '{@link #getOp() <em>Op</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getOp()
* @generated
* @ordered
*/
protected String op = OP_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected AttributeOperationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetValue(Expression newValue, NotificationChain msgs) {
Expression oldValue = value;
value = newValue;
if(eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(
this, Notification.SET, PPPackage.ATTRIBUTE_OPERATION__VALUE, oldValue, newValue);
if(msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch(featureID) {
case PPPackage.ATTRIBUTE_OPERATION__VALUE:
return getValue();
case PPPackage.ATTRIBUTE_OPERATION__KEY:
return getKey();
case PPPackage.ATTRIBUTE_OPERATION__OP:
return getOp();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch(featureID) {
case PPPackage.ATTRIBUTE_OPERATION__VALUE:
return basicSetValue(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch(featureID) {
case PPPackage.ATTRIBUTE_OPERATION__VALUE:
return value != null;
case PPPackage.ATTRIBUTE_OPERATION__KEY:
return KEY_EDEFAULT == null
? key != null
: !KEY_EDEFAULT.equals(key);
case PPPackage.ATTRIBUTE_OPERATION__OP:
return OP_EDEFAULT == null
? op != null
: !OP_EDEFAULT.equals(op);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch(featureID) {
case PPPackage.ATTRIBUTE_OPERATION__VALUE:
setValue((Expression) newValue);
return;
case PPPackage.ATTRIBUTE_OPERATION__KEY:
setKey((String) newValue);
return;
case PPPackage.ATTRIBUTE_OPERATION__OP:
setOp((String) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return PPPackage.Literals.ATTRIBUTE_OPERATION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch(featureID) {
case PPPackage.ATTRIBUTE_OPERATION__VALUE:
setValue((Expression) null);
return;
case PPPackage.ATTRIBUTE_OPERATION__KEY:
setKey(KEY_EDEFAULT);
return;
case PPPackage.ATTRIBUTE_OPERATION__OP:
setOp(OP_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public String getKey() {
return key;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public String getOp() {
return op;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public Expression getValue() {
return value;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public void setKey(String newKey) {
String oldKey = key;
key = newKey;
if(eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, PPPackage.ATTRIBUTE_OPERATION__KEY, oldKey, key));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public void setOp(String newOp) {
String oldOp = op;
op = newOp;
if(eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, PPPackage.ATTRIBUTE_OPERATION__OP, oldOp, op));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public void setValue(Expression newValue) {
if(newValue != value) {
NotificationChain msgs = null;
if(value != null)
msgs = ((InternalEObject) value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE -
PPPackage.ATTRIBUTE_OPERATION__VALUE, null, msgs);
if(newValue != null)
msgs = ((InternalEObject) newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE -
PPPackage.ATTRIBUTE_OPERATION__VALUE, null, msgs);
msgs = basicSetValue(newValue, msgs);
if(msgs != null)
msgs.dispatch();
}
else if(eNotificationRequired())
eNotify(new ENotificationImpl(
this, Notification.SET, PPPackage.ATTRIBUTE_OPERATION__VALUE, newValue, newValue));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public String toString() {
if(eIsProxy())
return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (key: ");
result.append(key);
result.append(", op: ");
result.append(op);
result.append(')');
return result.toString();
}
} // AttributeOperationImpl