| /** |
| * |
| * Copyright (c) 2009-2010 Thales Corporate Services S.A.S. |
| * 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: |
| * Thales Corporate Services S.A.S - initial API and implementation |
| * |
| */ |
| package org.eclipse.egf.model.pattern.impl; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.egf.model.pattern.Pattern; |
| import org.eclipse.egf.model.pattern.PatternPackage; |
| import org.eclipse.egf.model.pattern.Substitution; |
| import org.eclipse.egf.model.pattern.TypePatternSubstitution; |
| import org.eclipse.egf.model.types.impl.TypeImpl; |
| 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.util.EObjectContainmentEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object ' |
| * <em><b>Type Pattern Substitution</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li> |
| * {@link org.eclipse.egf.model.pattern.impl.TypePatternSubstitutionImpl#getSubstitutions |
| * <em>Substitutions</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class TypePatternSubstitutionImpl extends TypeImpl implements TypePatternSubstitution { |
| /** |
| * 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 cached value of the '{@link #getSubstitutions() |
| * <em>Substitutions</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getSubstitutions() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Substitution> substitutions; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| protected TypePatternSubstitutionImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return PatternPackage.Literals.TYPE_PATTERN_SUBSTITUTION; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public EList<Substitution> getSubstitutions() { |
| if (substitutions == null) { |
| substitutions = new EObjectContainmentEList<Substitution>(Substitution.class, this, PatternPackage.TYPE_PATTERN_SUBSTITUTION__SUBSTITUTIONS); |
| } |
| return substitutions; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public Class<?> getType() { |
| return org.eclipse.egf.model.pattern.TypePatternSubstitution.class; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| public EList<Pattern> getSubstitutions(Pattern pattern) { |
| for (Substitution sub : getSubstitutions()) { |
| if (pattern == null && sub.getOutgoing() == null) |
| return sub.getIncoming(); |
| else if (pattern != null && sub.getOutgoing() != null && pattern.getID().equals(sub.getOutgoing().getID())) |
| return sub.getIncoming(); |
| } |
| return null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case PatternPackage.TYPE_PATTERN_SUBSTITUTION__SUBSTITUTIONS: |
| return ((InternalEList<?>) getSubstitutions()).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 PatternPackage.TYPE_PATTERN_SUBSTITUTION__SUBSTITUTIONS: |
| return getSubstitutions(); |
| } |
| 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 PatternPackage.TYPE_PATTERN_SUBSTITUTION__SUBSTITUTIONS: |
| getSubstitutions().clear(); |
| getSubstitutions().addAll((Collection<? extends Substitution>) newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case PatternPackage.TYPE_PATTERN_SUBSTITUTION__SUBSTITUTIONS: |
| getSubstitutions().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case PatternPackage.TYPE_PATTERN_SUBSTITUTION__SUBSTITUTIONS: |
| return substitutions != null && !substitutions.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| @Override |
| public Object getValue() { |
| return this; |
| } |
| |
| } // TypePatternSubstitutionImpl |