Lines 12-28
Link Here
|
12 |
*/ |
12 |
*/ |
13 |
package org.eclipse.uml2.uml.internal.operations; |
13 |
package org.eclipse.uml2.uml.internal.operations; |
14 |
|
14 |
|
|
|
15 |
import java.util.Iterator; |
15 |
import java.util.Map; |
16 |
import java.util.Map; |
16 |
|
17 |
|
17 |
import org.eclipse.emf.common.util.BasicDiagnostic; |
18 |
import org.eclipse.emf.common.util.BasicDiagnostic; |
18 |
import org.eclipse.emf.common.util.Diagnostic; |
19 |
import org.eclipse.emf.common.util.Diagnostic; |
19 |
import org.eclipse.emf.common.util.DiagnosticChain; |
20 |
import org.eclipse.emf.common.util.DiagnosticChain; |
20 |
|
21 |
import org.eclipse.emf.common.util.EList; |
21 |
import org.eclipse.uml2.uml.Behavior; |
22 |
import org.eclipse.uml2.uml.Behavior; |
22 |
import org.eclipse.uml2.uml.UMLPackage; |
23 |
import org.eclipse.uml2.uml.BehavioralFeature; |
23 |
|
|
|
24 |
import org.eclipse.uml2.uml.BehavioredClassifier; |
24 |
import org.eclipse.uml2.uml.BehavioredClassifier; |
25 |
|
25 |
import org.eclipse.uml2.uml.Classifier; |
|
|
26 |
import org.eclipse.uml2.uml.Parameter; |
27 |
import org.eclipse.uml2.uml.UMLPackage; |
28 |
import org.eclipse.uml2.uml.UMLPlugin; |
26 |
import org.eclipse.uml2.uml.util.UMLValidator; |
29 |
import org.eclipse.uml2.uml.util.UMLValidator; |
27 |
|
30 |
|
28 |
/** |
31 |
/** |
Lines 62-91
Link Here
|
62 |
* The parameters of the behavior must match the parameters of the implemented behavioral feature. |
65 |
* The parameters of the behavior must match the parameters of the implemented behavioral feature. |
63 |
* true |
66 |
* true |
64 |
* <!-- end-model-doc --> |
67 |
* <!-- end-model-doc --> |
65 |
* @generated |
68 |
* @generated NOT |
66 |
*/ |
69 |
*/ |
67 |
public static boolean validateParametersMatch(Behavior behavior, |
70 |
public static boolean validateParametersMatch(Behavior behavior, |
68 |
DiagnosticChain diagnostics, Map context) { |
71 |
DiagnosticChain diagnostics, Map context) { |
69 |
// TODO: implement this method |
72 |
boolean result = true; |
70 |
// -> specify the condition that violates the invariant |
73 |
BehavioralFeature feature = behavior.getSpecification(); |
71 |
// -> verify the details of the diagnostic, including severity and message |
74 |
if (feature == null) { |
72 |
// Ensure that you remove @generated or mark it @generated NOT |
75 |
return result; |
73 |
if (false) { |
76 |
} |
|
|
77 |
EList featureParameters = feature.getOwnedParameters(); |
78 |
EList behaviorParameters = behavior.getOwnedParameters(); |
79 |
if (featureParameters.size() != behaviorParameters.size()) { |
80 |
result = false; |
81 |
} else { |
82 |
Iterator parmIter = featureParameters.iterator(); |
83 |
Iterator otherIter = behaviorParameters.iterator(); |
84 |
while (parmIter.hasNext() && otherIter.hasNext()) { |
85 |
if (!ParameterOperations.conformsTo( |
86 |
(Parameter) parmIter.next(), (Parameter) otherIter.next())) { |
87 |
result = false; |
88 |
break; |
89 |
} |
90 |
} |
91 |
} |
92 |
if (!result) { |
74 |
if (diagnostics != null) { |
93 |
if (diagnostics != null) { |
75 |
diagnostics |
94 |
diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, |
76 |
.add(new BasicDiagnostic( |
95 |
UMLValidator.DIAGNOSTIC_SOURCE, |
77 |
Diagnostic.ERROR, |
96 |
UMLValidator.BEHAVIOR__PARAMETERS_MATCH, UMLPlugin.INSTANCE |
78 |
UMLValidator.DIAGNOSTIC_SOURCE, |
97 |
.getString("_UI_Interface_ParametersMatch_diagnostic", //$NON-NLS-1$ |
79 |
UMLValidator.BEHAVIOR__PARAMETERS_MATCH, |
98 |
getMessageSubstitutions(context, behavior)), |
80 |
org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE |
99 |
new Object[]{behavior})); |
81 |
.getString( |
|
|
82 |
"_UI_GenericInvariant_diagnostic", new Object[]{"validateParametersMatch", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(behavior, context)}), //$NON-NLS-1$ //$NON-NLS-2$ |
83 |
new Object[]{behavior})); |
84 |
} |
100 |
} |
85 |
return false; |
|
|
86 |
} |
101 |
} |
87 |
return true; |
102 |
return result; |
88 |
} |
103 |
} |
|
|
104 |
|
89 |
|
105 |
|
90 |
/** |
106 |
/** |
91 |
* <!-- begin-user-doc --> |
107 |
* <!-- begin-user-doc --> |
Lines 94-122
Link Here
|
94 |
* The implemented behavioral feature must be a feature (possibly inherited) of the context classifier of the behavior. |
110 |
* The implemented behavioral feature must be a feature (possibly inherited) of the context classifier of the behavior. |
95 |
* true |
111 |
* true |
96 |
* <!-- end-model-doc --> |
112 |
* <!-- end-model-doc --> |
97 |
* @generated |
113 |
* @generated NOT |
98 |
*/ |
114 |
*/ |
99 |
public static boolean validateFeatureOfContextClassifier(Behavior behavior, |
115 |
public static boolean validateFeatureOfContextClassifier(Behavior behavior, |
100 |
DiagnosticChain diagnostics, Map context) { |
116 |
DiagnosticChain diagnostics, Map context) { |
101 |
// TODO: implement this method |
117 |
boolean result = true; |
102 |
// -> specify the condition that violates the invariant |
118 |
BehavioralFeature feature = behavior.getSpecification(); |
103 |
// -> verify the details of the diagnostic, including severity and message |
119 |
Classifier contextClassifier = behavior.getContext(); |
104 |
// Ensure that you remove @generated or mark it @generated NOT |
120 |
if (feature != null) { |
105 |
if (false) { |
121 |
result = (contextClassifier != null) |
106 |
if (diagnostics != null) { |
122 |
&& contextClassifier.allFeatures().contains(feature); |
107 |
diagnostics |
123 |
if (!result) { |
108 |
.add(new BasicDiagnostic( |
124 |
if (diagnostics != null) { |
109 |
Diagnostic.ERROR, |
125 |
diagnostics |
110 |
UMLValidator.DIAGNOSTIC_SOURCE, |
126 |
.add(new BasicDiagnostic( |
111 |
UMLValidator.BEHAVIOR__FEATURE_OF_CONTEXT_CLASSIFIER, |
127 |
Diagnostic.WARNING, |
112 |
org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE |
128 |
UMLValidator.DIAGNOSTIC_SOURCE, |
113 |
.getString( |
129 |
UMLValidator.BEHAVIOR__FEATURE_OF_CONTEXT_CLASSIFIER, |
114 |
"_UI_GenericInvariant_diagnostic", new Object[]{"validateFeatureOfContextClassifier", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(behavior, context)}), //$NON-NLS-1$ //$NON-NLS-2$ |
130 |
UMLPlugin.INSTANCE |
115 |
new Object[]{behavior})); |
131 |
.getString( |
|
|
132 |
"_UI_Interface_FeatureOfContextClassifier_diagnostic", //$NON-NLS-1$ |
133 |
getMessageSubstitutions(context, behavior)), |
134 |
new Object[]{behavior})); |
135 |
} |
116 |
} |
136 |
} |
117 |
return false; |
|
|
118 |
} |
137 |
} |
119 |
return true; |
138 |
return result; |
120 |
} |
139 |
} |
121 |
|
140 |
|
122 |
/** |
141 |
/** |
Lines 182-188
Link Here
|
182 |
} |
201 |
} |
183 |
return true; |
202 |
return true; |
184 |
} |
203 |
} |
185 |
|
204 |
|
186 |
/** |
205 |
/** |
187 |
* <!-- begin-user-doc --> |
206 |
* <!-- begin-user-doc --> |
188 |
* <!-- end-user-doc --> |
207 |
* <!-- end-user-doc --> |
Lines 192-196
Link Here
|
192 |
return (BehavioredClassifier) getOwningElement(behavior, |
211 |
return (BehavioredClassifier) getOwningElement(behavior, |
193 |
UMLPackage.Literals.BEHAVIORED_CLASSIFIER, false); |
212 |
UMLPackage.Literals.BEHAVIORED_CLASSIFIER, false); |
194 |
} |
213 |
} |
|
|
214 |
|
195 |
|
215 |
|
196 |
} // BehaviorOperations |
216 |
} // BehaviorOperations |