Create a new MQL script named returnType on the type uml21.Operation, and change the contents of the created uml21_Operation.mqs file to:
package tutorial.java; import com.sodius.mdw.metamodel.uml21.ParameterDirectionKind; metatype uml21.Operation; public script returnType() { return self.ownedParameter.detect("direction", com.sodius.mdw.metamodel.uml21.ParameterDirectionKind.RETURN_LITERAL).type; }
Here is the behavior of this returnType
script:
detect()
method to evaluate the attribute direction
on each parameter of this list.
This method will return the first parameter of the list whose direction
is equal to ParameterDirectionKind.RETURN_LITERAL
.type
of the return
parameter,
or null
if there is no return
parameter
(due to MDWorkbench's null management).Create a second MQL script named inParameters:
package tutorial.java; import com.sodius.mdw.metamodel.uml21.ParameterDirectionKind; metatype uml21.Operation; public script returnType() { return self.ownedParameter.detect("direction", com.sodius.mdw.metamodel.uml21.ParameterDirectionKind.RETURN_LITERAL).type; } public script inParameters() { return self.ownedParameter.reject("direction", com.sodius.mdw.metamodel.uml21.ParameterDirectionKind.RETURN_LITERAL); }
This inParameters
script does the opposite job of the returnType
script:
it uses the reject
method to keep only the parameters whose direction
is not ParameterDirectionKind.RETURN_LITERAL
.
You can navigate these scripts using the Scripts view.