| /******************************************************************************* |
| * Copyright (c) 2013, 2015 CEA LIST and others. |
| * 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: |
| * E.D.Willink(CEA LIST) - Initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ocl.examples.codegen.cgmodel.impl; |
| |
| import java.util.Collection; |
| import java.util.List; |
| |
| 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.EObjectContainmentWithInverseEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.jdt.annotation.Nullable; |
| import org.eclipse.ocl.examples.codegen.cgmodel.CGInvalid; |
| import org.eclipse.ocl.examples.codegen.cgmodel.CGModelPackage; |
| import org.eclipse.ocl.examples.codegen.cgmodel.CGTupleExp; |
| import org.eclipse.ocl.examples.codegen.cgmodel.CGTuplePart; |
| import org.eclipse.ocl.examples.codegen.cgmodel.CGValuedElement; |
| import org.eclipse.ocl.examples.codegen.cgmodel.util.CGModelVisitor; |
| import org.eclipse.ocl.examples.codegen.utilities.EquivalenceUtil; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>CG Tuple Exp</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGTupleExpImpl#getParts <em>Parts</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class CGTupleExpImpl extends CGValuedElementImpl implements CGTupleExp { |
| /** |
| * The cached value of the '{@link #getParts() <em>Parts</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getParts() |
| * @generated |
| * @ordered |
| */ |
| protected EList<CGTuplePart> parts; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected CGTupleExpImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return CGModelPackage.Literals.CG_TUPLE_EXP; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public List<CGTuplePart> getParts() { |
| if (parts == null) { |
| parts = new EObjectContainmentWithInverseEList<CGTuplePart>(CGTuplePart.class, this, CGModelPackage.CG_TUPLE_EXP__PARTS, CGModelPackage.CG_TUPLE_PART__TUPLE_EXP); |
| } |
| return parts; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case CGModelPackage.CG_TUPLE_EXP__PARTS: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getParts()).basicAdd(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 CGModelPackage.CG_TUPLE_EXP__PARTS: |
| return ((InternalEList<?>)getParts()).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 CGModelPackage.CG_TUPLE_EXP__PARTS: |
| return getParts(); |
| } |
| 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 CGModelPackage.CG_TUPLE_EXP__PARTS: |
| getParts().clear(); |
| getParts().addAll((Collection<? extends CGTuplePart>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case CGModelPackage.CG_TUPLE_EXP__PARTS: |
| getParts().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case CGModelPackage.CG_TUPLE_EXP__PARTS: |
| return parts != null && !parts.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public @Nullable <R> R accept(@NonNull CGModelVisitor<R> visitor) { |
| return visitor.visitCGTupleExp(this); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public @Nullable CGInvalid getInvalidValue() { |
| for (CGTuplePart cgPart : getParts()) { |
| CGInvalid invalidValue = cgPart.getInvalidValue(); |
| if (invalidValue != null) { |
| return invalidValue; |
| } |
| } |
| return null; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public @NonNull CGValuedElement getThisValue() { |
| CGInvalid invalidValue = getInvalidValue(); |
| if (invalidValue != null) { |
| return invalidValue; |
| } |
| else { |
| return this; |
| } |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isBoxed() { |
| return true; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isConstant() { |
| for (CGTuplePart cgPart : getParts()) { |
| if (!cgPart.isConstant()) { |
| return false; |
| } |
| } |
| return true; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isEcore() { |
| return false; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public @Nullable Boolean isEquivalentToInternal(@NonNull CGValuedElement thatValue) { |
| return (getClass() == thatValue.getClass()) ? EquivalenceUtil.isEquivalent(this, (CGTupleExp)thatValue) : null; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isGlobal() { |
| for (CGTuplePart cgPart : getParts()) { |
| if (!cgPart.isGlobal()) { |
| return false; |
| } |
| } |
| return true; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isNonInvalid() { |
| for (CGTuplePart cgPart : getParts()) { |
| if (!cgPart.isNonInvalid()) { |
| return false; |
| } |
| } |
| return true; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isNonNull() { |
| return true; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isNull() { |
| return false; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isUnboxed() { |
| return false; |
| } |
| |
| } //CGTupleExpImpl |