Altova UModel 2024 Professional Edition

UModel supports the use of UML templates and their mapping to or from Java, C# and Visual Basic generics.

 

Templates are "potential" model elements with unbound formal parameters.

These parameterized model elements, describe a group of model elements of a particular type: classifiers, or operations.

Templates cannot be used directly as types, the parameters have to be bound.

Instantiate means binding the template parameters to actual values.

Actual values for parameters are expressions.

The binding between a template and model element, produces a new model element (a bound element) based on the template.

If multiple constraining classifiers exist in C#, then the template parameters can be directly edited in the Properties tab, when the template parameter is selected.

 

Template signature display in UModel:

t-sig-1

Class template called MyVector, with formal template parameter "T", visible in the dashed rectangle.

Formal parameters without type info (T ) are implicitly classifiers: Class, Datatype, Enumeration, PrimitiveType, Interface. All other parameter types must be shown explicitly e.g. Integer.

Property myArray with unbounded number of elements of type T.

 

Right clicking the template and selecting Show | Bound elements, displays the actual bound elements.

 

Template binding display:

t-sig-2

A bound named template intvector

Template of type, MyVector, where

Parameter T is substituted/replaced by int.

"Substituted by" is shown by - >.

 

Template use in properties/operations:

t-sig-3

An anonymous template binding:

Property MyFloatVector of type MyVector<T->float>

 

Templates can also be defined when defining properties or operations. The autocomplete function helps you with the correct syntax when doing this.

 

t-sig-4

 

Operation1 returns a vector of floats.

© 2017-2023 Altova GmbH