All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.uml2.uml.internal.operations.ParameterOperations Maven / Gradle / Ivy

There is a newer version: 5.0.0-v20140602-0749
Show newest version
/*
 * Copyright (c) 2005, 2012 IBM Corporation, CEA, 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:
 *   IBM - initial API and implementation
 *   Kenn Hussey (CEA) - 327039, 351774, 313298
 *
 */
package org.eclipse.uml2.uml.internal.operations;

import java.util.Map;

import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;

import org.eclipse.uml2.uml.LiteralBoolean;
import org.eclipse.uml2.uml.LiteralInteger;
import org.eclipse.uml2.uml.LiteralNull;
import org.eclipse.uml2.uml.LiteralReal;
import org.eclipse.uml2.uml.LiteralString;
import org.eclipse.uml2.uml.LiteralUnlimitedNatural;
import org.eclipse.uml2.uml.Parameter;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.ValueSpecification;

import org.eclipse.uml2.uml.util.UMLValidator;

/**
 * 
 * A static utility class that provides operations related to 'Parameter' model objects.
 * 
 *
 * 

* The following operations are supported: *

    *
  • {@link org.eclipse.uml2.uml.Parameter#validateReentrantBehaviors(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) Validate Reentrant Behaviors}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#validateConnectorEnd(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) Validate Connector End}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#validateNotException(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) Validate Not Exception}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#validateInAndOut(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) Validate In And Out}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#validateStreamAndException(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) Validate Stream And Exception}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#isSetDefault() Is Set Default}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#setBooleanDefaultValue(boolean) Set Boolean Default Value}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#setDefault(java.lang.String) Set Default}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#setIntegerDefaultValue(int) Set Integer Default Value}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#setNullDefaultValue() Set Null Default Value}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#setRealDefaultValue(double) Set Real Default Value}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#setStringDefaultValue(java.lang.String) Set String Default Value}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#setUnlimitedNaturalDefaultValue(int) Set Unlimited Natural Default Value}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#unsetDefault() Unset Default}
  • *
  • {@link org.eclipse.uml2.uml.Parameter#getDefault() Get Default}
  • *
*

* * @generated */ public class ParameterOperations extends ConnectableElementOperations { /** * * * @generated */ protected ParameterOperations() { super(); } /** * * * * A parameter may only be associated with a connector end within the context of a collaboration. * self.end.notEmpty() implies self.collaboration.notEmpty() * @param parameter The receiving 'Parameter' model object. * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * * @generated */ public static boolean validateConnectorEnd(Parameter parameter, DiagnosticChain diagnostics, Map context) { // TODO: implement this method // -> specify the condition that violates the invariant // -> verify the details of the diagnostic, including severity and message // Ensure that you remove @generated or mark it @generated NOT if (false) { if (diagnostics != null) { diagnostics .add(new BasicDiagnostic( Diagnostic.ERROR, UMLValidator.DIAGNOSTIC_SOURCE, UMLValidator.PARAMETER__CONNECTOR_END, org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE .getString( "_UI_GenericInvariant_diagnostic", new Object[]{"validateConnectorEnd", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(parameter, context)}), //$NON-NLS-1$ //$NON-NLS-2$ new Object[]{parameter})); } return false; } return true; } /** * * * * A parameter cannot be a stream and exception at the same time. * true * @param parameter The receiving 'Parameter' model object. * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * * @generated */ public static boolean validateStreamAndException(Parameter parameter, DiagnosticChain diagnostics, Map context) { // TODO: implement this method // -> specify the condition that violates the invariant // -> verify the details of the diagnostic, including severity and message // Ensure that you remove @generated or mark it @generated NOT if (false) { if (diagnostics != null) { diagnostics .add(new BasicDiagnostic( Diagnostic.ERROR, UMLValidator.DIAGNOSTIC_SOURCE, UMLValidator.PARAMETER__STREAM_AND_EXCEPTION, org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE .getString( "_UI_GenericInvariant_diagnostic", new Object[]{"validateStreamAndException", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(parameter, context)}), //$NON-NLS-1$ //$NON-NLS-2$ new Object[]{parameter})); } return false; } return true; } /** * * * * An input parameter cannot be an exception. * true * @param parameter The receiving 'Parameter' model object. * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * * @generated */ public static boolean validateNotException(Parameter parameter, DiagnosticChain diagnostics, Map context) { // TODO: implement this method // -> specify the condition that violates the invariant // -> verify the details of the diagnostic, including severity and message // Ensure that you remove @generated or mark it @generated NOT if (false) { if (diagnostics != null) { diagnostics .add(new BasicDiagnostic( Diagnostic.ERROR, UMLValidator.DIAGNOSTIC_SOURCE, UMLValidator.PARAMETER__NOT_EXCEPTION, org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE .getString( "_UI_GenericInvariant_diagnostic", new Object[]{"validateNotException", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(parameter, context)}), //$NON-NLS-1$ //$NON-NLS-2$ new Object[]{parameter})); } return false; } return true; } /** * * * * Reentrant behaviors cannot have stream parameters. * true * @param parameter The receiving 'Parameter' model object. * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * * @generated */ public static boolean validateReentrantBehaviors(Parameter parameter, DiagnosticChain diagnostics, Map context) { // TODO: implement this method // -> specify the condition that violates the invariant // -> verify the details of the diagnostic, including severity and message // Ensure that you remove @generated or mark it @generated NOT if (false) { if (diagnostics != null) { diagnostics .add(new BasicDiagnostic( Diagnostic.ERROR, UMLValidator.DIAGNOSTIC_SOURCE, UMLValidator.PARAMETER__REENTRANT_BEHAVIORS, org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE .getString( "_UI_GenericInvariant_diagnostic", new Object[]{"validateReentrantBehaviors", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(parameter, context)}), //$NON-NLS-1$ //$NON-NLS-2$ new Object[]{parameter})); } return false; } return true; } /** * * * * Only in and inout parameters may have a delete effect. Only out, inout, and return parameters may have a create effect. * true * @param parameter The receiving 'Parameter' model object. * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * * @generated */ public static boolean validateInAndOut(Parameter parameter, DiagnosticChain diagnostics, Map context) { // TODO: implement this method // -> specify the condition that violates the invariant // -> verify the details of the diagnostic, including severity and message // Ensure that you remove @generated or mark it @generated NOT if (false) { if (diagnostics != null) { diagnostics .add(new BasicDiagnostic( Diagnostic.ERROR, UMLValidator.DIAGNOSTIC_SOURCE, UMLValidator.PARAMETER__IN_AND_OUT, org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE .getString( "_UI_GenericInvariant_diagnostic", new Object[]{"validateInAndOut", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(parameter, context)}), //$NON-NLS-1$ //$NON-NLS-2$ new Object[]{parameter})); } return false; } return true; } /** * * * @generated NOT */ public static String getDefault(Parameter parameter) { ValueSpecification defaultValue = parameter.getDefaultValue(); return defaultValue == null ? null : defaultValue.stringValue(); } /** * * * @generated NOT */ public static void setDefault(Parameter parameter, String newDefault) { ValueSpecification defaultValue = parameter.getDefaultValue(); if (defaultValue != null) { ValueSpecificationOperations.setValue(defaultValue, newDefault); } else { parameter.setStringDefaultValue(newDefault); } } /** * * * @generated NOT */ public static boolean isSetDefault(Parameter parameter) { return parameter.getDefault() != null; } /** * * * @generated NOT */ public static void unsetDefault(Parameter parameter) { if (parameter.isSetDefault()) { parameter.eUnset(UMLPackage.Literals.PARAMETER__DEFAULT_VALUE); } } /** * * * * Sets the default value for this parameter to the specified Boolean value. * @param parameter The receiving 'Parameter' model object. * @param value The new default value. * * @generated NOT */ public static void setBooleanDefaultValue(Parameter parameter, boolean value) { ValueSpecification defaultValue = parameter.getDefaultValue(); ((LiteralBoolean) (defaultValue instanceof LiteralBoolean ? defaultValue : parameter.createDefaultValue(null, null, UMLPackage.Literals.LITERAL_BOOLEAN))).setValue(value); } /** * * * * Sets the default value for this parameter to the specified integer value. * @param parameter The receiving 'Parameter' model object. * @param value The new default value. * * @generated NOT */ public static void setIntegerDefaultValue(Parameter parameter, int value) { ValueSpecification defaultValue = parameter.getDefaultValue(); ((LiteralInteger) (defaultValue instanceof LiteralInteger ? defaultValue : parameter.createDefaultValue(null, null, UMLPackage.Literals.LITERAL_INTEGER))).setValue(value); } /** * * * * Sets the default value for this parameter to the specified string value. * @param parameter The receiving 'Parameter' model object. * @param value The new default value. * * @generated NOT */ public static void setStringDefaultValue(Parameter parameter, String value) { ValueSpecification defaultValue = parameter.getDefaultValue(); ((LiteralString) (defaultValue instanceof LiteralString ? defaultValue : parameter.createDefaultValue(null, null, UMLPackage.Literals.LITERAL_STRING))).setValue(value); } /** * * * * Sets the default value for this parameter to the specified unlimited natural value. * @param parameter The receiving 'Parameter' model object. * @param value The new default value. * * @generated NOT */ public static void setUnlimitedNaturalDefaultValue(Parameter parameter, int value) { ValueSpecification defaultValue = parameter.getDefaultValue(); ((LiteralUnlimitedNatural) (defaultValue instanceof LiteralUnlimitedNatural ? defaultValue : parameter.createDefaultValue(null, null, UMLPackage.Literals.LITERAL_UNLIMITED_NATURAL))) .setValue(value); } /** * * * * Sets the default value for this parameter to the null value. * @param parameter The receiving 'Parameter' model object. * * @generated NOT */ public static void setNullDefaultValue(Parameter parameter) { if (!(parameter.getDefaultValue() instanceof LiteralNull)) { parameter.createDefaultValue(null, null, UMLPackage.Literals.LITERAL_NULL); } } /** * * * * Sets the default value for this parameter to the specified real value. * @param parameter The receiving 'Parameter' model object. * @param value The new default value. * * @generated NOT */ public static void setRealDefaultValue(Parameter parameter, double value) { ValueSpecification defaultValue = parameter.getDefaultValue(); ((LiteralReal) (defaultValue instanceof LiteralReal ? defaultValue : parameter.createDefaultValue(null, null, UMLPackage.Literals.LITERAL_REAL))).setValue(value); } protected static boolean matches(Parameter parameter, Parameter otherParameter) { Type type = parameter.getType(); Type otherType = otherParameter.getType(); return (type == null ? otherType == null : type.conformsTo(otherType)) && parameter.lowerBound() == otherParameter.lowerBound() && parameter.upperBound() == otherParameter.upperBound() && parameter.isOrdered() == otherParameter.isOrdered(); } } // ParameterOperations




© 2015 - 2024 Weber Informatics LLC | Privacy Policy