Java Reference
In-Depth Information
private
List[gmfgen::ToolGroup] collectSubGroups(gmfgen::ToolGroup
group) :
let
rv = group.entries.typeSelect(gmfgen::ToolGroup) :
rv.addAll(rv.collect(g| g.collectSubGroups()).flatten())
;
Cached Extensions
If you expect to have an extension called multiple times for a given set of param-
eters, you might want to have the result cached for performance reasons. This is
accomplished by adding the
cached
keyword to the expression, as in this exam-
ple from GMF's
xpt::navigator::Utils
extensions:
cached
List[gmfgen::GenCommonBase]
getNavigatorContainerNodes(gmfgen::GenNavigator navigator) :
getNavigatorNodes(navigator).select( n |
getChildReferencesFrom(navigator, n).size() > 0)
;
Private Extensions
If you do not want to expose an extension outside its file, you can add the
private
keyword, as shown in this example from GMF's
xpt::navigator::
Utils
extensions:
private
List[gmfgen::GenCommonBase]
getNavigatorNodes(gmfgen::GenNavigator navigator) :
let
diagram = navigator.editorGen.diagram :
{ diagram }
.addAll(diagram.topLevelNodes)
.addAll(diagram.childNodes)
.addAll(diagram.links)
.addAll(diagram.compartments)
.typeSelect(gmfgen::GenCommonBase)
;
Java Extensions
Sometimes you need to call a Java method. The
JAVA
keyword provides the
means by which to declare that a Java public static method is called. This is the
general syntax for defining a Java public static method:
Type
aJavaExtension(ParamType param, …) :
JAVA
package.Type.staticMethod(package.Type, …)
;
Search WWH ::
Custom Search