/******************************************************************************* * Copyright (c) 2010, 2015 Willink Transformations 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 - Initial API and implementation *******************************************************************************/ package org.eclipse.ocl.pivot.internal; import java.lang.reflect.InvocationTargetException; import java.util.Collection; import java.util.Map; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.EList; 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.pivot.Comment; import org.eclipse.ocl.pivot.Element; import org.eclipse.ocl.pivot.ElementExtension; import org.eclipse.ocl.pivot.Feature; import org.eclipse.ocl.pivot.PivotPackage; import org.eclipse.ocl.pivot.PivotTables; import org.eclipse.ocl.pivot.Type; import org.eclipse.ocl.pivot.ValueSpecification; import org.eclipse.ocl.pivot.ids.TypeId; import org.eclipse.ocl.pivot.internal.utilities.PivotUtilInternal; import org.eclipse.ocl.pivot.library.LibraryFeature; import org.eclipse.ocl.pivot.library.oclany.OclComparableLessThanEqualOperation; import org.eclipse.ocl.pivot.library.string.CGStringGetSeverityOperation; import org.eclipse.ocl.pivot.library.string.CGStringLogDiagnosticOperation; import org.eclipse.ocl.pivot.util.Visitor; import org.eclipse.ocl.pivot.utilities.ValueUtil; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Feature</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.eclipse.ocl.pivot.internal.FeatureImpl#getImplementation <em>Implementation</em>}</li> * <li>{@link org.eclipse.ocl.pivot.internal.FeatureImpl#getImplementationClass <em>Implementation Class</em>}</li> * <li>{@link org.eclipse.ocl.pivot.internal.FeatureImpl#isIsStatic <em>Is Static</em>}</li> * </ul> * * @generated */ public abstract class FeatureImpl extends TypedElementImpl implements Feature { /** * The default value of the '{@link #getImplementation() <em>Implementation</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getImplementation() * @generated * @ordered */ protected static final LibraryFeature IMPLEMENTATION_EDEFAULT = null; /** * The cached value of the '{@link #getImplementation() <em>Implementation</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getImplementation() * @generated * @ordered */ protected LibraryFeature implementation = IMPLEMENTATION_EDEFAULT; /** * The default value of the '{@link #getImplementationClass() <em>Implementation Class</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getImplementationClass() * @generated * @ordered */ protected static final String IMPLEMENTATION_CLASS_EDEFAULT = null; /** * The cached value of the '{@link #getImplementationClass() <em>Implementation Class</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getImplementationClass() * @generated * @ordered */ protected String implementationClass = IMPLEMENTATION_CLASS_EDEFAULT; /** * The default value of the '{@link #isIsStatic() <em>Is Static</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isIsStatic() * @generated * @ordered */ protected static final boolean IS_STATIC_EDEFAULT = false; /** * The flag representing the value of the '{@link #isIsStatic() <em>Is Static</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isIsStatic() * @generated * @ordered */ protected static final int IS_STATIC_EFLAG = 1 << 9; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected FeatureImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return PivotPackage.Literals.FEATURE; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String getImplementationClass() { return implementationClass; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setImplementationClass(String newImplementationClass) { String oldImplementationClass = implementationClass; implementationClass = newImplementationClass; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, PivotPackage.FEATURE__IMPLEMENTATION_CLASS, oldImplementationClass, implementationClass)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean isIsStatic() { return (eFlags & IS_STATIC_EFLAG) != 0; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setIsStatic(boolean newIsStatic) { boolean oldIsStatic = (eFlags & IS_STATIC_EFLAG) != 0; if (newIsStatic) eFlags |= IS_STATIC_EFLAG; else eFlags &= ~IS_STATIC_EFLAG; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, PivotPackage.FEATURE__IS_STATIC, oldIsStatic, newIsStatic)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean validateTypeIsNotInvalid(final DiagnosticChain diagnostics, final Map<Object, Object> context) { /** * * inv validateTypeIsNotInvalid: * let severity : Integer[1] = 'Feature::TypeIsNotInvalid'.getSeverity() * in * if severity <= 0 * then true * else * let status : OclAny[1] = type <> OclInvalid * in * 'Feature::TypeIsNotInvalid'.logDiagnostic(self, null, diagnostics, context, null, severity, status, 0) * endif */ final /*@NonInvalid*/ org.eclipse.ocl.pivot.evaluation.@NonNull Executor executor = PivotUtilInternal.getExecutor(this); final /*@NonInvalid*/ org.eclipse.ocl.pivot.ids.@NonNull IdResolver idResolver = executor.getIdResolver(); final /*@NonInvalid*/ org.eclipse.ocl.pivot.values.@NonNull IntegerValue severity_0 = CGStringGetSeverityOperation.INSTANCE.evaluate(executor, PivotTables.STR_Feature_c_c_TypeIsNotInvalid); final /*@NonInvalid*/ boolean le = OclComparableLessThanEqualOperation.INSTANCE.evaluate(executor, severity_0, PivotTables.INT_0).booleanValue(); /*@NonInvalid*/ boolean symbol_0; if (le) { symbol_0 = ValueUtil.TRUE_VALUE; } else { /*@Caught*/ @NonNull Object CAUGHT_status; try { final /*@NonInvalid*/ org.eclipse.ocl.pivot.@NonNull Class TYP_OclInvalid_0 = idResolver.getClass(TypeId.OCL_INVALID, null); final /*@Thrown*/ org.eclipse.ocl.pivot.@Nullable Type type = this.getType(); final /*@Thrown*/ boolean status = (type != null) ? (type.getTypeId() != TYP_OclInvalid_0.getTypeId()) : true; CAUGHT_status = status; } catch (Exception e) { CAUGHT_status = ValueUtil.createInvalidValue(e); } final /*@NonInvalid*/ boolean logDiagnostic = CGStringLogDiagnosticOperation.INSTANCE.evaluate(executor, TypeId.BOOLEAN, PivotTables.STR_Feature_c_c_TypeIsNotInvalid, this, null, diagnostics, context, null, severity_0, CAUGHT_status, PivotTables.INT_0).booleanValue(); symbol_0 = logDiagnostic; } return Boolean.TRUE == symbol_0; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public LibraryFeature getImplementation() { return implementation; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setImplementation(LibraryFeature newImplementation) { LibraryFeature oldImplementation = implementation; implementation = newImplementation; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, PivotPackage.FEATURE__IMPLEMENTATION, oldImplementation, implementation)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case PivotPackage.FEATURE__ANNOTATING_COMMENTS: return getAnnotatingComments(); case PivotPackage.FEATURE__OWNED_ANNOTATIONS: return getOwnedAnnotations(); case PivotPackage.FEATURE__OWNED_COMMENTS: return getOwnedComments(); case PivotPackage.FEATURE__OWNED_EXTENSIONS: return getOwnedExtensions(); case PivotPackage.FEATURE__NAME: return getName(); case PivotPackage.FEATURE__IS_MANY: return isIsMany(); case PivotPackage.FEATURE__IS_REQUIRED: return isIsRequired(); case PivotPackage.FEATURE__TYPE: if (resolve) return getType(); return basicGetType(); case PivotPackage.FEATURE__IMPLEMENTATION: return getImplementation(); case PivotPackage.FEATURE__IMPLEMENTATION_CLASS: return getImplementationClass(); case PivotPackage.FEATURE__IS_STATIC: return isIsStatic(); } return eDynamicGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case PivotPackage.FEATURE__ANNOTATING_COMMENTS: getAnnotatingComments().clear(); getAnnotatingComments().addAll((Collection<? extends Comment>)newValue); return; case PivotPackage.FEATURE__OWNED_ANNOTATIONS: getOwnedAnnotations().clear(); getOwnedAnnotations().addAll((Collection<? extends Element>)newValue); return; case PivotPackage.FEATURE__OWNED_COMMENTS: getOwnedComments().clear(); getOwnedComments().addAll((Collection<? extends Comment>)newValue); return; case PivotPackage.FEATURE__OWNED_EXTENSIONS: getOwnedExtensions().clear(); getOwnedExtensions().addAll((Collection<? extends ElementExtension>)newValue); return; case PivotPackage.FEATURE__NAME: setName((String)newValue); return; case PivotPackage.FEATURE__IS_REQUIRED: setIsRequired((Boolean)newValue); return; case PivotPackage.FEATURE__TYPE: setType((Type)newValue); return; case PivotPackage.FEATURE__IMPLEMENTATION: setImplementation((LibraryFeature)newValue); return; case PivotPackage.FEATURE__IMPLEMENTATION_CLASS: setImplementationClass((String)newValue); return; case PivotPackage.FEATURE__IS_STATIC: setIsStatic((Boolean)newValue); return; } eDynamicSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case PivotPackage.FEATURE__ANNOTATING_COMMENTS: getAnnotatingComments().clear(); return; case PivotPackage.FEATURE__OWNED_ANNOTATIONS: getOwnedAnnotations().clear(); return; case PivotPackage.FEATURE__OWNED_COMMENTS: getOwnedComments().clear(); return; case PivotPackage.FEATURE__OWNED_EXTENSIONS: getOwnedExtensions().clear(); return; case PivotPackage.FEATURE__NAME: setName(NAME_EDEFAULT); return; case PivotPackage.FEATURE__IS_REQUIRED: setIsRequired(IS_REQUIRED_EDEFAULT); return; case PivotPackage.FEATURE__TYPE: setType((Type)null); return; case PivotPackage.FEATURE__IMPLEMENTATION: setImplementation(IMPLEMENTATION_EDEFAULT); return; case PivotPackage.FEATURE__IMPLEMENTATION_CLASS: setImplementationClass(IMPLEMENTATION_CLASS_EDEFAULT); return; case PivotPackage.FEATURE__IS_STATIC: setIsStatic(IS_STATIC_EDEFAULT); return; } eDynamicUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case PivotPackage.FEATURE__ANNOTATING_COMMENTS: return annotatingComments != null && !annotatingComments.isEmpty(); case PivotPackage.FEATURE__OWNED_ANNOTATIONS: return ownedAnnotations != null && !ownedAnnotations.isEmpty(); case PivotPackage.FEATURE__OWNED_COMMENTS: return ownedComments != null && !ownedComments.isEmpty(); case PivotPackage.FEATURE__OWNED_EXTENSIONS: return ownedExtensions != null && !ownedExtensions.isEmpty(); case PivotPackage.FEATURE__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case PivotPackage.FEATURE__IS_MANY: return isIsMany() != IS_MANY_EDEFAULT; case PivotPackage.FEATURE__IS_REQUIRED: return ((eFlags & IS_REQUIRED_EFLAG) != 0) != IS_REQUIRED_EDEFAULT; case PivotPackage.FEATURE__TYPE: return type != null; case PivotPackage.FEATURE__IMPLEMENTATION: return IMPLEMENTATION_EDEFAULT == null ? implementation != null : !IMPLEMENTATION_EDEFAULT.equals(implementation); case PivotPackage.FEATURE__IMPLEMENTATION_CLASS: return IMPLEMENTATION_CLASS_EDEFAULT == null ? implementationClass != null : !IMPLEMENTATION_CLASS_EDEFAULT.equals(implementationClass); case PivotPackage.FEATURE__IS_STATIC: return ((eFlags & IS_STATIC_EFLAG) != 0) != IS_STATIC_EDEFAULT; } return eDynamicIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override @SuppressWarnings("unchecked") public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case PivotPackage.FEATURE___ALL_OWNED_ELEMENTS: return allOwnedElements(); case PivotPackage.FEATURE___GET_VALUE__TYPE_STRING: return getValue((Type)arguments.get(0), (String)arguments.get(1)); case PivotPackage.FEATURE___COMPATIBLE_BODY__VALUESPECIFICATION: return CompatibleBody((ValueSpecification)arguments.get(0)); case PivotPackage.FEATURE___VALIDATE_TYPE_IS_NOT_INVALID__DIAGNOSTICCHAIN_MAP: return validateTypeIsNotInvalid((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1)); } return eDynamicInvoke(operationID, arguments); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ @Override public String toString() { return super.toString(); } @Override public <R> R accept(@NonNull Visitor<R> visitor) { return visitor.visitFeature(this); } } //FeatureImpl