One-to-One Aggregation

The following example describes how to aggregate a struct class, PersonDetails, into to another struct class, PersonDetailsWrapper, using one-to-one aggregation.

To create a one-to-one aggregation create an Rational Software Architect diagram and do the following:

This creates the aggregation relationship whereby one role corresponds to class PersonDetailsWrapper and the other to class PersonDetails. A UML role is essentially one end of a UML relationship so each relationship has two roles whose names are Role A and Role B. Exactly one of these roles - usually Role A - will have its Aggregate option set. The assignment of Role A and Role B is arbitrary. The key thing to remember is that the role which has the Aggregate box checked denotes the outermost class of the pair.

With the relationship line selected in the diagram the General Properties tab should show PersonDetailsWrapper in the graphic at the top of the properties sheet with the diamond associated with it. Set the following properties of the aggregation:

The class diagram would appear in the Rational Software Architect showing the two classes joined by the UML aggregation relationship line (diamond end touching PersonDetailsWrapper) and each side of the relationship showing multiplicity of one and the PersonDetails showing a role name of - dtls.

Note: The position of the diamond in the model diagram is important as it denotes the outermost class in the pair.

The generated Java code resulting from this construct would take the following format:

public final class PersonDetails implements
java.io.Serializable, curam.util.type.DeepCloneable {
  public String personRefNo = "";
  public String firstName = "";
};
public final class PersonDetailsWrapper implements
java.io.Serializable, curam.util.type.DeepCloneable {
  // This class has a single instance of
// class "PersonDetails" embedded in it. PersonDetails dtls =
//   new PersonDetails();
};