Unique Attributes
[Previous]  [Next] 
|
User Manual [Previous]  [Next] Unique AttributesAttributes in Umple can be unique. Applying the unique keyword to an attribute ensures that each instance of the class in the currently running program has a unique value for that attribute. In the first example, each player has a unique ranking. The ranking of a player can change but two players cannot have the same ranking. The autounique keyword can be used to automatically assign a unique Integer to every new instance created (example 2). Certain runtime errors can occur if attempts are made to violate uniqueness. Example 1// Every player has a ranking. // Rankings can be modified, // but two different players // can not have the same ranking. class Player { unique Integer ranking; } Load the above code into UmpleOnline Example 2// Unique registration numbers (Integer) // are automatically assigned to every // new registration created class Registration { autounique registrationNumber; } Load the above code into UmpleOnline SyntaxautouniqueAttribute- : [=autounique] [~name] ; complexAttribute- : [=unique]? [=lazy]? [=ivar]? [=modifier:immutable  |settable  |internal  |defaulted  |const  |fixml]? [[typedName]]  (= [**value]  )? ; |