blob: b488f21a53df46fd5154117b41db363a9b7be6c8 [file] [log] [blame]
/*******************************************************************************
* 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 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.CGString;
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 String</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGStringImpl#getStringValue <em>String Value</em>}</li>
* </ul>
*
* @generated
*/
public class CGStringImpl extends CGConstantImpl implements CGString {
/**
* The default value of the '{@link #getStringValue() <em>String Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getStringValue()
* @generated
* @ordered
*/
protected static final String STRING_VALUE_EDEFAULT = null;
/**
* The cached value of the '{@link #getStringValue() <em>String Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getStringValue()
* @generated
* @ordered
*/
protected String stringValue = STRING_VALUE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CGStringImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CGModelPackage.Literals.CG_STRING;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getStringValue() {
return stringValue;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setStringValue(String newStringValue) {
String oldStringValue = stringValue;
stringValue = newStringValue;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CGModelPackage.CG_STRING__STRING_VALUE, oldStringValue, stringValue));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
return super.toString();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case CGModelPackage.CG_STRING__STRING_VALUE:
return getStringValue();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case CGModelPackage.CG_STRING__STRING_VALUE:
setStringValue((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CGModelPackage.CG_STRING__STRING_VALUE:
setStringValue(STRING_VALUE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CGModelPackage.CG_STRING__STRING_VALUE:
return STRING_VALUE_EDEFAULT == null ? stringValue != null : !STRING_VALUE_EDEFAULT.equals(stringValue);
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable <R> R accept(@NonNull CGModelVisitor<R> visitor) {
return visitor.visitCGString(this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @NonNull Object getConstantValue() {
return ClassUtil.nonNullState(stringValue);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isCommonable() {
return true;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable Boolean isEquivalentToInternal(@NonNull CGValuedElement thatValue) {
if (!thatValue.isNonInvalid()) {
return null;
}
CGValuedElement value = thatValue.getNamedValue();
if (this == value) {
return Boolean.TRUE;
}
if (!value.isConstant()) {
return null;
}
else if (value instanceof CGString) {
return stringValue.equals(((CGString)thatValue).getStringValue());
}
else {
return Boolean.FALSE;
}
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isUncommonable() {
return false;
}
} //CGStringImpl