Operation

<operation> is a child element of <class> or <interface> and defines a Java method.

Usage

The name attribute is mandatory and indicates the name of the method. Syntax of the operation element:

<operation/> example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<pattern>
        ...
        <operation name=""
                   visibility=""
                   static=""
                   abstract=""
                   final=""
                   foreach="package|object|attribute|reference| object.attribute|object.reference|
                            currentModelPackage.property|currentModelObject.property|
                            currentModelAttribute.property|currentModelReference.property"
                   condition=""
                   package=""
                   var0=""
                   var1=""
                   var2=""
                   var3=""
                   var4=""
                   var5="">

            <library></library>
            <apicomment></apicomment>
            <developercomment></developercomment>
            <annotation></annotation>
            <parameter name="">
                <datatype></datatype>
            </parameter>
            <exception></exception>
            <body></body>
        </operation>

        ...
</pattern>

Attributes

attributes of <operation/>

Name

Details

name

The name of the java method made. When you name it “constructor” it will create a constructor.

visibility

Visibility of the method. Possible values are public, protected en private. If left empty, then private is used.

static

true or false. Indicates whether or not the method should be defined static.

abstract

true or false. Indicates whether or not the method should be defined abstract.

final

true or false. Indicates whether or not the method should be defined final.

foreach

Indicates if operation must be created foreach element in model (value of foreach determines what model element). Possible values: package, object, attribute, reference

condition

An expression that evaluates to true or false. Generation of the current file wil precede if true and otherwise not. Example: .. code-block:

condition="${object.name}=Person"

In this case, the package is generated only if the current model object has the name: Person. This works only if all model objects are iterated (foreach=”object”).

package

The name of the package in the model (model.xml) that must be used to apply the foreach attribute.

object

The name of the object in the model (model.xml) that must be used to apply the foreach attribute.

var0

Value that you wish to store in the pre-defined variable with the name var0. Reference to this value can be made later by means of: ${var0}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var1

Value that you wish to store in the pre-defined variable with the name var1. Reference to this value can be made later by means of: ${var1}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var2

Value that you wish to store in the pre-defined variable with the name var2. Reference to this value can be made later by means of: ${var2}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var3

Value that you wish to store in the pre-defined variable with the name var3. Reference to this value can be made later by means of: ${var3}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var4

Value that you wish to store in the pre-defined variable with the name var4. Reference to this value can be made later by means of: ${var4}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var5

Value that you wish to store in the pre-defined variable with the name var5. Reference to this value can be made later by means of: ${var5}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

Sub elements

sub elements of <operation/>

Name

Details

Number

library

The value of library is attached as an import statement to the class or interface in which this attribute is defined.

0 or 1

apicomment

Javadoc that is attached to this method.

0 or 1

developercomment

Commentary that is attached to this attribute.

0 or 1

annotation

Annotation defined for the attribute.

0 or more

parameter

Parameter of this method. The parameter with the name ‘return is reserved for specifying the return parameter.

0 or more

exception

Exception thrown by this method.

0 or more

body

The contents of the method.

0 or 1

Sub element Parameter