Code Injection Pattern Matching
[Previous]  [Next] 
|
User Manual [Previous]  [Next] Code Injection Pattern MatchingWhen creating before and after statements, you can arrange for the code to be injected into certain methods that match a pattern. You can use * as a wildcard, and ! as an exclusion operator. The following examples will both generate the same code. Another example of pattern matching for code injection can be found on the page on pooled state machines, where the same code is injected into all the event methods matching a certain pattern You can specify that code should be injected only into generated methods by specifying the word 'generated' after before or after. Similarly you can specify only custom methods using the keyword 'custom'. The keyword 'all' indicates to inject the code into all matching methods. Exampleclass Student { const Boolean DEBUG = true; firstName; lastName; cityOfBirth; before get*Name { if ( DEBUG) { System.out.println("accessing the name"); } } } // @@@skipcppcompile Load the above code into UmpleOnline Another Exampleclass Student { const Boolean DEBUG = true; firstName; lastName; cityOfBirth; before get*,!getCityOfBirth { if ( DEBUG) { System.out.println("accessing the name"); } } } Load the above code into UmpleOnline |