Java Reference
In-Depth Information
operators with inv , we can achieve the inverse—for example, invresolve ,
invresolveone , invresolveIn , and so on.
late
When performing transformations, resolving objects that were not yet created
during the execution of a mapping might require more than one pass over a
model. To solve this problem, you can modify resolution operators with a late
operator to defer evaluation until the end of the transformation. This technique
is always used with assignment operators, where a null assignment is created
until resolution is completed. Use transformation properties instead of local vari-
ables so that they are valid when the transformation ends.
Keep in mind that the left side of a late resolution statement is not re-
executed along with the right-side deferred statement. This means that you can-
not expect to use the result of the deferred assignment in a later expression. For
example, the following assignment of the variable p is not the result of the
resolve operation; the result is null because that was assigned during the nor-
mal execution.
mapping mindmap::Topic::toRequirement() : requirements::Requirement {
parent := self .parent. late resolve (requirements::Requirement)
->asSet();
end {
var p := result .parent->asOrderedSet();
}
}
Furthermore, late resolutions are invoked sequentially at the end of the
transformation in the order they were encountered during normal execution.
Don't rely on the result of a late resolution that might not have been executed.
As we mentioned earlier, invoking our example mapping from the end block
ensures that we can resolve Requirement objects created from our Topic objects.
We can alter this approach using the late resolution operator, which defers res-
olution until the end of the transformation and provides the same outcome.
Following is an example of this approach:
property dependencies : Set (Relationship) = null ;
mapping main ( in mmap : mindmap::Map, out req : requirements::Model) {
init {
this .dependencies := mmap.dependencies();
. . .
}
}
Search WWH ::




Custom Search