import

Syntax

[#import] packageName.simpleName [/#import]
or
[#import] packageName.* [/#import]

where:

Description

The import tag makes the referenced Java type directly available in the template. You can then use the element using its simple name, rather than having to use a qualified name. You may also make the whole content of a package directly available using the '*' (star) character.

When an element is referenced in the template contents using a simple name (e.g. MyElement), the element is resolved this way:

  1. The element is searched in the template declared package.
  2. If not found, it is searched in the named imports (e.g. import com.mycompany.example.MyElement)
  3. If not found, it is searched in the package imports (e.g. import com.mycompany.example.*)

Examples

A template that won't compile due to an unresolved type:

[#parameters] values : List [/#parameters]

The template can be rewritten to use a qualified name:

[#parameters] values : java.util.List [/#parameters]
[#comment] java.util.List is valid [/#comment]

Or we can introduce an import to keep the simple notation:

[#import]java.util.List[/#import]
[#parameters] values : List [/#parameters]
[#comment] List is resolved to java.util.List [/#comment]