Generalization references

In xUML, a subclass holds a reference to the identifier of its superclass. The references are set initially set by the creation action. If the subclass instances can change subclasses, the migrate action deletes the old subclass instance and creates the new subclass instances setting the appropriate referential attributes.

Any attributes not referring to the superclass in the old subclass are deleted. Any additional attributes required in the new subclass must be initialized as they would be in a create action.

Instead of requiring the modeler to delete, create and reset referential attribute values, the migrate action can be used.

Consider the following class model snippet from the Air Traffic Controller example introduced in the book Models to Code, Starr/Mangogna/Mellor, Apress 2017:

 
 

In the most common usage, the local instance belongs to a super or subclass. The following action is in a state activity of an Air Traffic Controller superclass.

migrate to On Duty Controller( Time logged in: _now.MDY_HMS, &R3 Duty Station( Number: in.assigned station ) )

When migrating, a new instance is created. And this requires enough information to initialize all attributes and associations. In this case the Time logged in attribute is set to the current time and the assigned Duty Station instance is linked using the & set reference operator. The old Off Duty Controller instance is deleted along with its Last shift ended attribute.

Note that no source instance was specified. The migrate action then assumes that the local instance is the one that is migrating.

If migrating from a remote instance you would specify both the source instance and target subclass:

migrate anOffDutyATC to On Duty Controller(...)

This works for instance sets as well:

migrate Unowned Dog(*) to Owned Dog

This action migrates all Unowned Dog instances to Owned Dog instances. The * operator selects all instances of a class. It is not possible to specify multiple attributes or associations for the new subclass when the target set contains more than one instance. In that case, each instance must be initialized separately.