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
Author:
Marek Potociar, Santiago Pericas-Geertsen (Santiago.PericasGeertsen at oracle.com)
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 consumes(String type)
          Convenience method to set a consumes type on this link.
 Link.Builder method(String method)
          Convenience method to set a type on this link.
 Link.Builder param(String name, String value)
          Set an arbitrary parameter on this link.
 Link.Builder produces(String type)
          Convenience method to set a produces type on this link.
 Link.Builder rel(String name)
          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
Since:
2.0

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
Since:
2.0

rel

public Link.Builder rel(String name)
Convenience method to set a link relation. More than one rel value can be specified using this method.

Parameters:
name - relation name
Returns:
the updated builder

title

public Link.Builder title(String title)
Convenience method to set a title on this link. If called more than once, the previous value of title is overwritten.

Parameters:
title - title parameter of this link
Returns:
the updated builder

type

public Link.Builder type(String type)
Convenience method to set a type on this link. More than one type value can be specified using this method.

Parameters:
type - link type as string
Returns:
the updated builder

method

public Link.Builder method(String method)
Convenience method to set a type on this link. If called more than once, the previous value of method is overwritten.

Parameters:
method - HTTP method name
Returns:
the updated builder

produces

public Link.Builder produces(String type)
Convenience method to set a produces type on this link. More than one type value can be specified using this method.

Parameters:
type - link type as string
Returns:
the updated builder

consumes

public Link.Builder consumes(String type)
Convenience method to set a consumes type on this link. More than one type value can be specified using this method.

Parameters:
type - link type as string
Returns:
the updated builder

param

public Link.Builder param(String name,
                          String value)
                   throws IllegalArgumentException
Set an arbitrary parameter on this link. This method supports adding more than one parameter value for each parameter. It is recommended to use the more specific methods method(java.lang.String) or title(java.lang.String) when setting these single-valued parameters.

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.

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:
UriBuilderException - maybe thrown when building underlying URI


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.