Top-level Aspects
[Previous]  [Next] 
|
User Manual [Previous]  [Next] Top-level AspectsAspects in Umple can also be specified at top level (i.e. outside any classes). In this case, a set of classes in which to inject the code must be specified, within curly brackets. Glob patterns can be used to match a set of classes, where an asterisk is the wildcard character. Example with "after" statement that will inject code in all set functions in all classesafter {*} set* { doSomething(); } class Student1 { name; } class Student2 { name; } class Employer { age; String testFunction() { return "This is a test function"; } } class Student1 {isA X;} class Student2 {isA X;} class Employer {isA X;} trait X { doSomething() { System.out.println("Doing something\n"); } } Load the above code into UmpleOnline Example that will inject code after two specific methods in all classes starting with Studentafter {Student*} setName,testFunction { doSomething(); } class Student1 { name; } class Student2 { name; } class Employer { age; String testFunction() { return "This is a test function"; } } class Student1 {isA X;} class Student2 {isA X;} trait X { doSomething() { System.out.println("Doing something\n"); } } Load the above code into UmpleOnline SyntaxtoplevelCodeInjection- : [[toplevelBeforeCode]] | [[toplevelAfterCode]] toplevelBeforeCode : ( before | [=around] ) {([className])(, [className])*} [[aspectBody]] toplevelAfterCode : after {  ([className]  )  (, [className]  )*} [[aspectBody]] |