uOttawaUniversity of Ottawa - Canadas University
list of dots

Umple User Manual    [Previous]   [Next]   

Loading

W045 Initialized Value in Key

Umple semantic warning reported when an attribute in the key is given an initial value

If an attribute is given an initial value and is part of a key, then there is potential for keys of all instances of a class to be the same, meaning that they would be treated as equal and would have the same hash value. It is unlikely that a developer intends for this to be the case, so a warning is thrown to inform them of this behaviour.

Example

// This example generates the message
class X {
  Integer z = 1;
  key { z }
}


      

Load the above code into UmpleOnline

 

Another Example

// The following shows how to avoid the message
class X {
  Integer z;
  key { z  }
}


      

Load the above code into UmpleOnline