Template Signatures

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Projects and Code Engineering > UML Templates  >

Template Signatures

A Template signature is a string that specifies the formal template parameters. A template is a parameterized element that is used to generate new model elements by substituting/binding the formal parameters to actual parameters (values).

 

Formal template parameter

T

Template with a single untyped formal parameter

(stores elements of type T)

 

 

Multiple formal template parameters

KeyType:DateType, ValueType

 

 

Parameter substitution

T>aBaseClass

 

The parameter substitution must be of type "aBaseClass", or derived from it.

 

Default values for template parameters

T=aDefaultValue

 

Substituting classifiers

T>{contract}aBaseClass

 

allowsSubstitutable is true

Parameter must be a classifier that may be substituted for the classifier designated by the classifier name.

 

 

Constraining template parameters

T:Interface>anInterface

 

When constraining to anything other than a class, (interface, data type), the constraint is displayed after the colon ":" character. E.g. T is constrained to an interface (T:Interface) which must be of type "anInterface" (>anInterface).

 

Using wildcards in template signatures

T>vector<T->?<aBaseClass>

 

Template parameter T must be of type "vector" which contains objects which are a supertype of aBaseClass.

 

 

Extending template parameters

T>Comparable<T->T>


© 2019 Altova GmbH