public Link buildLink(Object fromInstance, Object toInstance) {
   Link link = createLink();
   LinkEnd le0 = createLinkEnd();
   le0.setInstance((Instance) fromInstance);
   LinkEnd le1 = createLinkEnd();
   le1.setInstance((Instance) toInstance);
   link.getConnection().add(le0);
   link.getConnection().add(le1);
   return link;
 }
  /**
   * when a linkend is deleted, delete its Links.
   *
   * @param elem the element to be deleted
   */
  void deleteLinkEnd(Object elem) {
    if (!(elem instanceof LinkEnd)) {
      throw new IllegalArgumentException("elem: " + elem);
    }

    Link link = ((LinkEnd) elem).getLink();
    if (link != null
        && link.getConnection() != null
        && link.getConnection().size() == 2) { // binary link
      modelImpl.getUmlFactory().delete(link);
    }
  }