Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (25 sloc) 1.52 KB
Before and After Statements
Aspect Orientation
<p>You can request that certain code be run before or after
various Umple-defined actions on attributes, associations, and the
components of state machines as well as on user-defined methods.<p>
<p>Using 'before' allows you to enforce preconditions, such that
the attribute or association will not be set if the precondition
is not true. To reject setting a value, add 'return false'.</p>
<p>Code in a setMethod can access the value to be set by prefacing it by &apos;a&apos; as in the second example or &apos;an&apos;.</p>
<p>You can add before and after clauses to add code to generated methods of the form getX, setX, addX, removeX, getXs (to get all elements of an association), numberOfXs, indexOfX, where X is the name of the attribute or association. You can also add code before and
after the constructor.</p>
<p><a href="InterfacingtoExternalCode.html">See also this example of using aspect-orientation to help interface Umple with existing libraries.</a>
[[codeInjection]] [[beforeCode]] [[afterCode]]
@@example @@caption Example with &quot;after&quot; statement @@endcaption
@@source manualexamples/BeforeandAfterStatements1.ump
@@example @@caption Example with &quot;before&quot; statement @@endcaption
@@source manualexamples/BeforeandAfterStatements2.ump
@@example @@caption Example with both &quot;before&quot; and &quot;after&quot; statements @@endcaption
@@source manualexamples/BeforeandAfterStatements3.ump
You can’t perform that action at this time.