/** * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * * http://www.apache.org/licenses/LICENSE-2.0 * * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.thingml.xtext.thingML.impl; import java.util.Collection; 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.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; import org.thingml.xtext.thingML.Expression; import org.thingml.xtext.thingML.Property; import org.thingml.xtext.thingML.PropertyAssign; import org.thingml.xtext.thingML.ThingMLPackage; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Property Assign</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.thingml.xtext.thingML.impl.PropertyAssignImpl#getProperty <em>Property</em>}</li> * <li>{@link org.thingml.xtext.thingML.impl.PropertyAssignImpl#getIndex <em>Index</em>}</li> * <li>{@link org.thingml.xtext.thingML.impl.PropertyAssignImpl#getInit <em>Init</em>}</li> * </ul> * * @generated */ public class PropertyAssignImpl extends AnnotatedElementImpl implements PropertyAssign { /** * The cached value of the '{@link #getProperty() <em>Property</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getProperty() * @generated * @ordered */ protected Property property; /** * The cached value of the '{@link #getIndex() <em>Index</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getIndex() * @generated * @ordered */ protected EList<Expression> index; /** * The cached value of the '{@link #getInit() <em>Init</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getInit() * @generated * @ordered */ protected Expression init; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected PropertyAssignImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return ThingMLPackage.Literals.PROPERTY_ASSIGN; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Property getProperty() { if (property != null && property.eIsProxy()) { InternalEObject oldProperty = (InternalEObject)property; property = (Property)eResolveProxy(oldProperty); if (property != oldProperty) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, ThingMLPackage.PROPERTY_ASSIGN__PROPERTY, oldProperty, property)); } } return property; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Property basicGetProperty() { return property; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setProperty(Property newProperty) { Property oldProperty = property; property = newProperty; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ThingMLPackage.PROPERTY_ASSIGN__PROPERTY, oldProperty, property)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Expression> getIndex() { if (index == null) { index = new EObjectContainmentEList<Expression>(Expression.class, this, ThingMLPackage.PROPERTY_ASSIGN__INDEX); } return index; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Expression getInit() { return init; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetInit(Expression newInit, NotificationChain msgs) { Expression oldInit = init; init = newInit; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThingMLPackage.PROPERTY_ASSIGN__INIT, oldInit, newInit); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setInit(Expression newInit) { if (newInit != init) { NotificationChain msgs = null; if (init != null) msgs = ((InternalEObject)init).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.PROPERTY_ASSIGN__INIT, null, msgs); if (newInit != null) msgs = ((InternalEObject)newInit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.PROPERTY_ASSIGN__INIT, null, msgs); msgs = basicSetInit(newInit, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ThingMLPackage.PROPERTY_ASSIGN__INIT, newInit, newInit)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ThingMLPackage.PROPERTY_ASSIGN__INDEX: return ((InternalEList<?>)getIndex()).basicRemove(otherEnd, msgs); case ThingMLPackage.PROPERTY_ASSIGN__INIT: return basicSetInit(null, 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 ThingMLPackage.PROPERTY_ASSIGN__PROPERTY: if (resolve) return getProperty(); return basicGetProperty(); case ThingMLPackage.PROPERTY_ASSIGN__INDEX: return getIndex(); case ThingMLPackage.PROPERTY_ASSIGN__INIT: return getInit(); } 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 ThingMLPackage.PROPERTY_ASSIGN__PROPERTY: setProperty((Property)newValue); return; case ThingMLPackage.PROPERTY_ASSIGN__INDEX: getIndex().clear(); getIndex().addAll((Collection<? extends Expression>)newValue); return; case ThingMLPackage.PROPERTY_ASSIGN__INIT: setInit((Expression)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ThingMLPackage.PROPERTY_ASSIGN__PROPERTY: setProperty((Property)null); return; case ThingMLPackage.PROPERTY_ASSIGN__INDEX: getIndex().clear(); return; case ThingMLPackage.PROPERTY_ASSIGN__INIT: setInit((Expression)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ThingMLPackage.PROPERTY_ASSIGN__PROPERTY: return property != null; case ThingMLPackage.PROPERTY_ASSIGN__INDEX: return index != null && !index.isEmpty(); case ThingMLPackage.PROPERTY_ASSIGN__INIT: return init != null; } return super.eIsSet(featureID); } } //PropertyAssignImpl