Java Code Examples for javax.ws.rs.core.Link#getUri()

The following examples show how to use javax.ws.rs.core.Link#getUri() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceSupport.java    From container with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(final Link link, final JsonGenerator json,
                      final SerializerProvider provider) throws IOException {
    if (link.getUri() == null || link.getRel() == null || link.getRel().isEmpty()) {
        return;
    }
    json.writeObjectFieldStart(link.getRel());
    json.writeStringField("href", link.getUri().toString());
    if (link.getTitle() != null && !link.getTitle().isEmpty()) {
        json.writeStringField(Link.TITLE, link.getTitle());
    }
    if (link.getType() != null && !link.getType().isEmpty()) {
        json.writeStringField(Link.TYPE, link.getType());
    }
    json.writeEndObject();
}
 
Example 2
Source File: LinkAdapter.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
/**
 * Convert a {@link Link} into a {@link JaxbLink}.
 *
 * @param v instance of type {@link Link}.
 * @return mapped instance of type {@link JaxbLink}.
 */
@Override
public JaxbLink marshal(Link v) {
    if (v == null) {
       return null;
    }

    final JaxbLink jl = new JaxbLink(v.getUri());
    if (v.getParams() != null) {
        for (Map.Entry<String, String> e : v.getParams().entrySet()) {
            jl.getParams().put(e.getKey(), e.getValue());
        }
    }
    return jl;
}
 
Example 3
Source File: LinkService.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
private Link getFullLink(final URI baseUri, final Link relativeLink) {
    final URI relativeUri = relativeLink.getUri();

    final URI fullUri = UriBuilder.fromUri(baseUri)
            .path(relativeUri.getPath())
            .build();

    return Link.fromUri(fullUri)
            .rel(relativeLink.getRel())
            .build();
}
 
Example 4
Source File: Customers.java    From resteasy-examples with Apache License 2.0 5 votes vote down vote up
@XmlTransient
public URI getNext()
{
   if (links == null) return null;
   for (Link link : links)
   {
      if ("next".equals(link.getRel())) return link.getUri();
   }
   return null;
}
 
Example 5
Source File: Customers.java    From resteasy-examples with Apache License 2.0 5 votes vote down vote up
@XmlTransient
public URI getPrevious()
{
   if (links == null) return null;
   for (Link link : links)
   {
      if ("previous".equals(link.getRel())) return link.getUri();
   }
   return null;
}
 
Example 6
Source File: Customers.java    From resteasy-examples with Apache License 2.0 5 votes vote down vote up
@XmlTransient
public URI getNext()
{
   if (links == null) return null;
   for (Link link : links)
   {
      if ("next".equals(link.getRel())) return link.getUri();
   }
   return null;
}
 
Example 7
Source File: Customers.java    From resteasy-examples with Apache License 2.0 5 votes vote down vote up
@XmlTransient
public URI getPrevious()
{
   if (links == null) return null;
   for (Link link : links)
   {
      if ("previous".equals(link.getRel())) return link.getUri();
   }
   return null;
}
 
Example 8
Source File: Orders.java    From resteasy-examples with Apache License 2.0 5 votes vote down vote up
@XmlTransient
public URI getNext()
{
   if (links == null) return null;
   for (Link link : links)
   {
      if ("next".equals(link.getRel())) return link.getUri();
   }
   return null;
}
 
Example 9
Source File: Orders.java    From resteasy-examples with Apache License 2.0 5 votes vote down vote up
@XmlTransient
public URI getPrevious()
{
   if (links == null) return null;
   for (Link link : links)
   {
      if ("previous".equals(link.getRel())) return link.getUri();
   }
   return null;
}