blob: 42d3b91a78373f667c2365e361aa4e9a888fc0d6 [file] [log] [blame]
/**
* <copyright>
*
* Copyright (c) 2015, 2019 Willink Transformations and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* E.D.Willink - Initial API and implementation
*
* </copyright>
*/
package org.eclipse.ocl.examples.codegen.cgmodel.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.examples.codegen.cgmodel.CGModelPackage;
import org.eclipse.ocl.examples.codegen.cgmodel.CGTemplateParameterExp;
import org.eclipse.ocl.examples.codegen.cgmodel.CGValuedElement;
import org.eclipse.ocl.examples.codegen.cgmodel.util.CGModelVisitor;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>CG Template Parameter Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGTemplateParameterExpImpl#getTemplateableElement <em>Templateable Element</em>}</li>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGTemplateParameterExpImpl#getIndex <em>Index</em>}</li>
* </ul>
*
* @generated
*/
public class CGTemplateParameterExpImpl extends CGValuedElementImpl implements CGTemplateParameterExp {
/**
* The number of structural features of the '<em>CG Template Parameter Exp</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int CG_TEMPLATE_PARAMETER_EXP_FEATURE_COUNT = CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 2;
/**
* The cached value of the '{@link #getTemplateableElement() <em>Templateable Element</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTemplateableElement()
* @generated
* @ordered
*/
protected CGValuedElement templateableElement;
/**
* The default value of the '{@link #getIndex() <em>Index</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIndex()
* @generated
* @ordered
*/
protected static final int INDEX_EDEFAULT = 0;
/**
* The cached value of the '{@link #getIndex() <em>Index</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIndex()
* @generated
* @ordered
*/
protected int index = INDEX_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CGTemplateParameterExpImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CGModelPackage.Literals.CG_TEMPLATE_PARAMETER_EXP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGValuedElement getTemplateableElement() {
return templateableElement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setTemplateableElement(CGValuedElement newTemplateableElement) {
CGValuedElement oldTemplateableElement = templateableElement;
templateableElement = newTemplateableElement;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, 6, oldTemplateableElement, templateableElement));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int getIndex() {
return index;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setIndex(int newIndex) {
int oldIndex = index;
index = newIndex;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, 7, oldIndex, index));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case 6:
return getTemplateableElement();
case 7:
return getIndex();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case 6:
setTemplateableElement((CGValuedElement)newValue);
return;
case 7:
setIndex((Integer)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case 6:
setTemplateableElement((CGValuedElement)null);
return;
case 7:
setIndex(INDEX_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case 6:
return templateableElement != null;
case 7:
return index != INDEX_EDEFAULT;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (index: ");
result.append(index);
result.append(')');
return result.toString();
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public <R> R accept(@NonNull CGModelVisitor<R> visitor) {
return visitor.visitCGTemplateParameterExp(this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isBoxed() {
return true;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isEcore() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable Boolean isEquivalentToInternal(@NonNull CGValuedElement thatValue) {
if (thatValue instanceof CGTemplateParameterExp) {
return Boolean.FALSE;
}
CGTemplateParameterExp thatExp = (CGTemplateParameterExp)thatValue;
int thatIndex = thatExp.getIndex();
if (this.index != thatIndex) {
return Boolean.FALSE;
}
return templateableElement.isEquivalentTo(ClassUtil.nonNullState(thatExp.getTemplateableElement()));
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isUnboxed() {
return false;
}
} //CGTemplateParameterExpImpl