/******************************************************************************* * Copyright (c) 2010 Martin Schnabel <mb0@mb0.org>. * 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.axdt.as3.model.impl; import java.util.Collection; import org.axdt.as3.As3EPackage; import org.axdt.as3.model.As3Variable; import org.axdt.as3.model.As3VariableDefinition; 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.MinimalEObjectImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>As3 Variable Definition</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.axdt.as3.model.impl.As3VariableDefinitionImpl#isConstant <em>Constant</em>}</li> * <li>{@link org.axdt.as3.model.impl.As3VariableDefinitionImpl#getBindings <em>Bindings</em>}</li> * </ul> * </p> * * @generated */ public class As3VariableDefinitionImpl extends MinimalEObjectImpl.Container implements As3VariableDefinition { /** * A set of bit flags representing the values of boolean attributes and whether unsettable features have been set. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ protected int flags = 0; /** * The default value of the '{@link #isConstant() <em>Constant</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isConstant() * @generated * @ordered */ protected static final boolean CONSTANT_EDEFAULT = false; /** * The flag representing the value of the '{@link #isConstant() <em>Constant</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isConstant() * @generated * @ordered */ protected static final int CONSTANT_EFLAG = 1 << 0; /** * The cached value of the '{@link #getBindings() <em>Bindings</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getBindings() * @generated * @ordered */ protected EList<As3Variable> bindings; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected As3VariableDefinitionImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return As3EPackage.Literals.AS3_VARIABLE_DEFINITION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean isConstant() { return (flags & CONSTANT_EFLAG) != 0; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setConstant(boolean newConstant) { boolean oldConstant = (flags & CONSTANT_EFLAG) != 0; if (newConstant) flags |= CONSTANT_EFLAG; else flags &= ~CONSTANT_EFLAG; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, As3EPackage.AS3_VARIABLE_DEFINITION__CONSTANT, oldConstant, newConstant)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<As3Variable> getBindings() { if (bindings == null) { bindings = new EObjectContainmentEList<As3Variable>(As3Variable.class, this, As3EPackage.AS3_VARIABLE_DEFINITION__BINDINGS); } return bindings; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case As3EPackage.AS3_VARIABLE_DEFINITION__BINDINGS: return ((InternalEList<?>)getBindings()).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 As3EPackage.AS3_VARIABLE_DEFINITION__CONSTANT: return isConstant(); case As3EPackage.AS3_VARIABLE_DEFINITION__BINDINGS: return getBindings(); } 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 As3EPackage.AS3_VARIABLE_DEFINITION__CONSTANT: setConstant((Boolean)newValue); return; case As3EPackage.AS3_VARIABLE_DEFINITION__BINDINGS: getBindings().clear(); getBindings().addAll((Collection<? extends As3Variable>)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case As3EPackage.AS3_VARIABLE_DEFINITION__CONSTANT: setConstant(CONSTANT_EDEFAULT); return; case As3EPackage.AS3_VARIABLE_DEFINITION__BINDINGS: getBindings().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case As3EPackage.AS3_VARIABLE_DEFINITION__CONSTANT: return ((flags & CONSTANT_EFLAG) != 0) != CONSTANT_EDEFAULT; case As3EPackage.AS3_VARIABLE_DEFINITION__BINDINGS: return bindings != null && !bindings.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(" (constant: "); result.append((flags & CONSTANT_EFLAG) != 0); result.append(')'); return result.toString(); } } //As3VariableDefinitionImpl