org.jboss.resteasy.spi.LinkHeaders Maven / Gradle / Ivy
package org.jboss.resteasy.spi;
import org.jboss.resteasy.plugins.delegates.LinkHeaderDelegate;
import javax.ws.rs.core.Link;
import javax.ws.rs.core.MultivaluedMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Abstraction for LInk headers. Also uses JAXRS classes rather than deprecated old resteasy ones.
*
* @author Bill Burke
* @version $Revision: 1 $
*/
public class LinkHeaders
{
private Map linksByRelationship = new HashMap();
private Map linksByTitle = new HashMap();
private List links = new ArrayList();
public LinkHeaders addLinks(MultivaluedMap headers)
{
List values = headers.get("Link");
if (values == null) return this;
for (String val : values)
{
LinkHeader linkHeader = new LinkHeaderDelegate().fromString(val);
for (org.jboss.resteasy.spi.Link link : linkHeader.getLinks())
{
addLink(link.toJaxrsLink());
}
}
return this;
}
public LinkHeaders addLinkObjects(MultivaluedMap headers, HeaderValueProcessor factory)
{
List