/** * <copyright> * Copyright (c) 2010-2014 Henshin developers. 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 * </copyright> */ package org.eclipse.emf.henshin.model.impl; 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.util.EcoreUtil; import org.eclipse.emf.henshin.model.AttributeCondition; import org.eclipse.emf.henshin.model.HenshinPackage; import org.eclipse.emf.henshin.model.Rule; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Attribute Condition</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.emf.henshin.model.impl.AttributeConditionImpl#getRule <em>Rule</em>}</li> * <li>{@link org.eclipse.emf.henshin.model.impl.AttributeConditionImpl#getConditionText <em>Condition Text</em>}</li> * </ul> * </p> * * @generated */ public class AttributeConditionImpl extends NamedElementImpl implements AttributeCondition { /** * The default value of the '{@link #getConditionText() <em>Condition Text</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getConditionText() * @generated * @ordered */ protected static final String CONDITION_TEXT_EDEFAULT = null; /** * The cached value of the '{@link #getConditionText() <em>Condition Text</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getConditionText() * @generated * @ordered */ protected String conditionText = CONDITION_TEXT_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public AttributeConditionImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return HenshinPackage.Literals.ATTRIBUTE_CONDITION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Rule getRule() { if (eContainerFeatureID() != HenshinPackage.ATTRIBUTE_CONDITION__RULE) return null; return (Rule)eInternalContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetRule(Rule newRule, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newRule, HenshinPackage.ATTRIBUTE_CONDITION__RULE, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setRule(Rule newRule) { if (newRule != eInternalContainer() || (eContainerFeatureID() != HenshinPackage.ATTRIBUTE_CONDITION__RULE && newRule != null)) { if (EcoreUtil.isAncestor(this, newRule)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newRule != null) msgs = ((InternalEObject)newRule).eInverseAdd(this, HenshinPackage.RULE__ATTRIBUTE_CONDITIONS, Rule.class, msgs); msgs = basicSetRule(newRule, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, HenshinPackage.ATTRIBUTE_CONDITION__RULE, newRule, newRule)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getConditionText() { return conditionText; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setConditionText(String newConditionText) { String oldConditionText = conditionText; conditionText = newConditionText; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, HenshinPackage.ATTRIBUTE_CONDITION__CONDITION_TEXT, oldConditionText, conditionText)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case HenshinPackage.ATTRIBUTE_CONDITION__RULE: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetRule((Rule)otherEnd, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case HenshinPackage.ATTRIBUTE_CONDITION__RULE: return basicSetRule(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case HenshinPackage.ATTRIBUTE_CONDITION__RULE: return eInternalContainer().eInverseRemove(this, HenshinPackage.RULE__ATTRIBUTE_CONDITIONS, Rule.class, msgs); } return super.eBasicRemoveFromContainerFeature(msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case HenshinPackage.ATTRIBUTE_CONDITION__RULE: return getRule(); case HenshinPackage.ATTRIBUTE_CONDITION__CONDITION_TEXT: return getConditionText(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case HenshinPackage.ATTRIBUTE_CONDITION__RULE: setRule((Rule)newValue); return; case HenshinPackage.ATTRIBUTE_CONDITION__CONDITION_TEXT: setConditionText((String)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case HenshinPackage.ATTRIBUTE_CONDITION__RULE: setRule((Rule)null); return; case HenshinPackage.ATTRIBUTE_CONDITION__CONDITION_TEXT: setConditionText(CONDITION_TEXT_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case HenshinPackage.ATTRIBUTE_CONDITION__RULE: return getRule() != null; case HenshinPackage.ATTRIBUTE_CONDITION__CONDITION_TEXT: return CONDITION_TEXT_EDEFAULT == null ? conditionText != null : !CONDITION_TEXT_EDEFAULT.equals(conditionText); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ @Override public String toString() { return conditionText; } } //AttributeConditionImpl