code: public void remove() {
  
      if (context == null) {
        throw new IllegalStateException("link with href=" + getHref() + " can not be removed, because it's not part of a HAL resource tree");
      }
  
      // iterate over all links grouped by relation (because for removal we need to know the relation)
      ListMultimap<String, Link> allLinks = context.getLinks();
      for (String relation : allLinks.keySet()) {
        List<Link> links = allLinks.get(relation);
  
        // use an indexed for-loop, because we need to know the index to properly remove the link
        for (int i = 0; i < links.size(); i++) {
          if (links.get(i).getModel() == model) {
            context.removeLink(relation, i);
            context = null;
            return;
          }
        }
      }
  
      throw new IllegalStateException("the last known context resource of link with href=" + getHref() + " no longer contains this link");
    }
docs: Removes this link from its context resource's JSON representation
  @throws IllegalStateException if this link was never added to a resource, or has already been removed