| /******************************************************************************* |
| * 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.Map; |
| import org.eclipse.emf.common.util.DiagnosticChain; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.jdt.annotation.Nullable; |
| import org.eclipse.ocl.pivot.CollectionLiteralPart; |
| 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.evaluation.Executor; |
| import org.eclipse.ocl.pivot.ids.IdResolver; |
| import org.eclipse.ocl.pivot.ids.TypeId; |
| import org.eclipse.ocl.pivot.internal.utilities.PivotUtilInternal; |
| 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; |
| import org.eclipse.ocl.pivot.values.IntegerValue; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Collection Literal Part</b></em>'. |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public abstract class CollectionLiteralPartImpl |
| extends TypedElementImpl |
| implements CollectionLiteralPart { |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected CollectionLiteralPartImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return PivotPackage.Literals.COLLECTION_LITERAL_PART; |
| } |
| |
| /** |
| * <!-- 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] = 'CollectionLiteralPart::TypeIsNotInvalid'.getSeverity() |
| * in |
| * if severity <= 0 |
| * then true |
| * else |
| * let status : OclAny[1] = type <> OclInvalid |
| * in |
| * 'CollectionLiteralPart::TypeIsNotInvalid'.logDiagnostic(self, null, diagnostics, context, null, severity, status, 0) |
| * endif |
| */ |
| final @NonNull /*@NonInvalid*/ Executor executor = PivotUtilInternal.getExecutor(this); |
| final @NonNull /*@NonInvalid*/ IdResolver idResolver = executor.getIdResolver(); |
| final @NonNull /*@NonInvalid*/ IntegerValue severity_0 = CGStringGetSeverityOperation.INSTANCE.evaluate(executor, PivotTables.STR_CollectionLiteralPart_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 { |
| @NonNull /*@Caught*/ Object CAUGHT_status; |
| try { |
| final @NonNull /*@NonInvalid*/ org.eclipse.ocl.pivot.Class TYP_OclInvalid_0 = idResolver.getClass(TypeId.OCL_INVALID, null); |
| final @Nullable /*@Thrown*/ 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_CollectionLiteralPart_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 |
| @SuppressWarnings("unchecked") |
| public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException |
| { |
| switch (operationID) |
| { |
| case PivotPackage.COLLECTION_LITERAL_PART___ALL_OWNED_ELEMENTS: |
| return allOwnedElements(); |
| case PivotPackage.COLLECTION_LITERAL_PART___GET_VALUE__TYPE_STRING: |
| return getValue((Type)arguments.get(0), (String)arguments.get(1)); |
| case PivotPackage.COLLECTION_LITERAL_PART___COMPATIBLE_BODY__VALUESPECIFICATION: |
| return CompatibleBody((ValueSpecification)arguments.get(0)); |
| case PivotPackage.COLLECTION_LITERAL_PART___VALIDATE_TYPE_IS_NOT_INVALID__DIAGNOSTICCHAIN_MAP: |
| return validateTypeIsNotInvalid((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1)); |
| } |
| return eDynamicInvoke(operationID, arguments); |
| } |
| |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| return visitor.visitCollectionLiteralPart(this); |
| } |
| |
| } //CollectionLiteralPartImpl |