All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.resteasy.spi.LinkHeader Maven / Gradle / Ivy

There is a newer version: 4.0.0.Beta5
Show newest version
package org.jboss.resteasy.spi;

import org.jboss.resteasy.plugins.delegates.LinkHeaderDelegate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Bill Burke
 * @version $Revision: 1 $
 */
public class LinkHeader
{
   private Map linksByRelationship = new HashMap();
   private Map linksByTitle = new HashMap();
   private List links = new ArrayList();

   public LinkHeader addLink(final Link link)
   {
      links.add(link);
      return this;
   }

   public LinkHeader addLink(final String title, final String rel, final String href, final String type)
   {
      final Link link = new Link(title, rel, href, type, null);
      return addLink(link);
   }

   public Link getLinkByTitle(String title)
   {
      return linksByTitle.get(title);
   }

   public Link getLinkByRelationship(String rel)
   {
      return linksByRelationship.get(rel);
   }

   /**
    * Index of links by relationship "rel" or "rev"
    *
    * @return map
    */
   public Map getLinksByRelationship()
   {
      return linksByRelationship;
   }

   /**
    * Index of links by title
    *
    * @return map
    */
   public Map getLinksByTitle()
   {
      return linksByTitle;
   }

   /**
    * All the links defined
    *
    * @return links
    */
   public List getLinks()
   {
      return links;
   }

   public static LinkHeader valueOf(String val)
   {
      return LinkHeaderDelegate.from(val);
   }

   public String toString()
   {
      return LinkHeaderDelegate.getString(this);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy