blob: 0e895d5dcd516b9e8c32878424aba743ef6a6baf [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2013, 2019 CEA LIST 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(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.CGBoolean;
import org.eclipse.ocl.examples.codegen.cgmodel.CGModelPackage;
import org.eclipse.ocl.examples.codegen.cgmodel.CGValuedElement;
import org.eclipse.ocl.examples.codegen.cgmodel.util.CGModelVisitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>CG Boolean</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGBooleanImpl#isBooleanValue <em>Boolean Value</em>}</li>
* </ul>
*
* @generated
*/
public class CGBooleanImpl extends CGConstantImpl implements CGBoolean {
/**
* The number of structural features of the '<em>CG Boolean</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int CG_BOOLEAN_FEATURE_COUNT = CGConstantImpl.CG_CONSTANT_FEATURE_COUNT + 1;
/**
* The default value of the '{@link #isBooleanValue() <em>Boolean Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isBooleanValue()
* @generated
* @ordered
*/
protected static final boolean BOOLEAN_VALUE_EDEFAULT = false;
/**
* The cached value of the '{@link #isBooleanValue() <em>Boolean Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isBooleanValue()
* @generated
* @ordered
*/
protected boolean booleanValue = BOOLEAN_VALUE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CGBooleanImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CGModelPackage.Literals.CG_BOOLEAN;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean isBooleanValue() {
return booleanValue;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setBooleanValue(boolean newBooleanValue) {
boolean oldBooleanValue = booleanValue;
booleanValue = newBooleanValue;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, 6, oldBooleanValue, booleanValue));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@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 6:
return isBooleanValue();
}
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:
setBooleanValue((Boolean)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case 6:
setBooleanValue(BOOLEAN_VALUE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case 6:
return booleanValue != BOOLEAN_VALUE_EDEFAULT;
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public <R> R accept(@NonNull CGModelVisitor<R> visitor) {
return visitor.visitCGBoolean(this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @NonNull Object getConstantValue() {
return booleanValue == true;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable Boolean isEquivalentToInternal(@NonNull CGValuedElement thatValue) {
if (this == thatValue) {
return Boolean.TRUE;
}
if (booleanValue) {
if (thatValue.isTrue()) {
return Boolean.TRUE;
}
else if (thatValue.isFalse()) {
return Boolean.FALSE;
}
}
else {
if (thatValue.isTrue()) {
return Boolean.FALSE;
}
else if (thatValue.isFalse()) {
return Boolean.TRUE;
}
}
if (thatValue.isConstant()) {
return Boolean.FALSE;
}
else {
return null;
}
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isFalse() {
return booleanValue == false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isInlined() {
return true;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isTrue() {
return booleanValue == true;
}
} //CGBooleanImpl