MagicDraw: Template Bindings

I wanted to create a class diagram for a method returning a Collection<Object[]> (that is, a Collection of Object arrays).

Why would I need something returning that type of thing?  For JUnit parameterized tests.

It wasn’t immediately clear to me how to do this… but here’s how it ended up:

  1. Create a class.  Name it Collection<Object[]> (which is what it will be in the end if this works!)
  2. In its Specification, go to Relations:
  3. Choose Create Outgoing…
  4. …Template Binding:
  5. In box that pops up, open the JDK 5.0 Classes folder and navigate to java.util.  Find the Collection interfaces.  Interestingly enough, we want the Collection one, not the Collection<E> one — Select the “< >” under the plain Collection interface:

    …and click OK.
  6. Back at the class’s Relations page, press the Edit button:
  7. On the Template Binding dialog that comes up, go to the Template Parameter Substitutions page:
  8. Then choose press Create, and check the template parameter you want to fill in:
  9. Fill in the Actual field as Object… but because we want an object array, we also need to choose to show All properties, and then choose [] for the Type Modifier field:

…and we’re done.

Or, we could just reverse engineer the code…  : )

Advertisements

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s