4.4.2.6. Library

Using <library> is the way to add import statements to a Java Class or Interface. Inside a pattern this element can be a child of <operation> or <attribute>. Defining imports on an operation (or attribute) rather than the parent class has the advantage that the import lines are only added when that operation is actually generated, and not when the condition attribute of the operation returns false. Zero or more library elements can be used.

Usage

Listing 4.32 Syntax
1
2
3
<library foreach="package|object" condition="" package="" object="">
        some.class.tobe.imported
</library>

Attributes

Table 4.33 attributes of <library/>

Name

Details

foreach

Indicates whether the interface must be created for each element in model (value of foreach determines what model element). Possible values: package, object.

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 library 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.