javax.ws.rs.core
Class Link.Builder

java.lang.Object
  extended by javax.ws.rs.core.Link.Builder
Enclosing class:
Link

public static class Link.Builder
extends Object

Builder class for hypermedia links.

Since:
2.0
See Also:
Link

Constructor Summary
Link.Builder()
           
 
Method Summary
 Link build()
          Finish building this link and return the instance.
 Link build(Object... values)
          Finish building this link using the supplied values as URI parameters.
 Link.Builder param(String name, String value)
          Set an arbitrary parameter on this link.
 Link.Builder rel(String rel)
          Convenience method to set a link relation.
 Link.Builder title(String title)
          Convenience method to set a "title" on this link.
 Link.Builder type(String type)
          Convenience method to set a "type" on this link.
 Link.Builder uri(String uri)
          Set underlying string representing URI template for the link being constructed.
 Link.Builder uri(URI uri)
          Set underlying URI template for the link being constructed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Link.Builder

public Link.Builder()
Method Detail

uri

public Link.Builder uri(URI uri)
Set underlying URI template for the link being constructed.

Parameters:
uri - underlying URI for link
Returns:
the updated builder.

uri

public Link.Builder uri(String uri)
                 throws IllegalArgumentException
Set underlying string representing URI template for the link being constructed.

Parameters:
uri - underlying URI for link.
Returns:
the updated builder.
Throws:
IllegalArgumentException - if string representation of URI is invalid.

rel

public Link.Builder rel(String rel)
Convenience method to set a link relation. More than one "rel" value can be specified by using one or more whitespace characters as delimiters according to RFC 5988. The effect of calling this method is cumulative; relations are appended using a single space character as separator.

Parameters:
rel - relation name.
Returns:
the updated builder.
Throws:
IllegalArgumentException - if the name is null.

title

public Link.Builder title(String title)
Convenience method to set a "title" on this link.

Parameters:
title - title parameter of this link.
Returns:
the updated builder.
Throws:
IllegalArgumentException - if the title is null.

type

public Link.Builder type(String type)
Convenience method to set a "type" on this link.

Parameters:
type - type parameter of this link.
Returns:
the updated builder.
Throws:
IllegalArgumentException - if the type is null.

param

public Link.Builder param(String name,
                          String value)
                   throws IllegalArgumentException
Set an arbitrary parameter on this link.

Parameters:
name - the name of the parameter.
value - the value set for the parameter.
Returns:
the updated builder.
Throws:
IllegalArgumentException - if either the name or value are null.

build

public Link build()
Finish building this link and return the instance.

Returns:
newly built link.
Throws:
IllegalArgumentException - if there are any URI template parameters without a supplied value.
UriBuilderException - if a URI cannot be constructed based on the current state of the builder.

build

public Link build(Object... values)
           throws UriBuilderException
Finish building this link using the supplied values as URI parameters.

Parameters:
values - parameters used to build underlying URI.
Returns:
the updated builder.
Throws:
IllegalArgumentException - if there are any URI template parameters without a supplied value, or if a value is null.
UriBuilderException - if a URI cannot be constructed based on the current state of the underlying URI builder.


Copyright © 2012. All Rights Reserved.