Spring Hateoas

org.springframework.hateoas.mvc
Class ControllerLinkBuilder

java.lang.Object
  extended by org.springframework.hateoas.core.LinkBuilderSupport<ControllerLinkBuilder>
      extended by org.springframework.hateoas.mvc.ControllerLinkBuilder
All Implemented Interfaces:
LinkBuilder

public class ControllerLinkBuilder
extends LinkBuilderSupport<ControllerLinkBuilder>

Builder to ease building Link instances pointing to Spring MVC controllers.

Author:
Oliver Gierke, Kamill Sokol

Method Summary
protected  ControllerLinkBuilder createNewInstance(UriComponentsBuilder builder)
          Creates a new instance of the sub-class.
protected  ControllerLinkBuilder getThis()
          Returns the current concrete instance.
static ControllerLinkBuilder linkTo(Class<?> controller)
          Creates a new ControllerLinkBuilder with a base of the mapping annotated to the given controller class.
static ControllerLinkBuilder linkTo(Class<?> controller, Object... parameters)
          Creates a new ControllerLinkBuilder with a base of the mapping annotated to the given controller class.
static ControllerLinkBuilder linkTo(Method method, Object... parameters)
           
static ControllerLinkBuilder linkTo(Object invocationValue)
          Creates a ControllerLinkBuilder pointing to a controller method.
static
<T> T
methodOn(Class<T> controller, Object... parameters)
          Wrapper for DummyInvocationUtils.methodOn(Class, Object...) to be available in case you work with static imports of ControllerLinkBuilder.
 UriComponentsBuilder toUriComponentsBuilder()
          Returns a UriComponentsBuilder to continue to build the already built URI in a more fine grained way.
 
Methods inherited from class org.springframework.hateoas.core.LinkBuilderSupport
slash, slash, toString, toUri, withRel, withSelfRel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

linkTo

public static ControllerLinkBuilder linkTo(Class<?> controller)
Creates a new ControllerLinkBuilder with a base of the mapping annotated to the given controller class.

Parameters:
controller - the class to discover the annotation on, must not be null.
Returns:

linkTo

public static ControllerLinkBuilder linkTo(Class<?> controller,
                                           Object... parameters)
Creates a new ControllerLinkBuilder with a base of the mapping annotated to the given controller class. The additional parameters are used to fill up potentially available path variables in the class scop request mapping.

Parameters:
controller - the class to discover the annotation on, must not be null.
parameters - additional parameters to bind to the URI template declared in the annotation, must not be null.
Returns:

linkTo

public static ControllerLinkBuilder linkTo(Method method,
                                           Object... parameters)

linkTo

public static ControllerLinkBuilder linkTo(Object invocationValue)
Creates a ControllerLinkBuilder pointing to a controller method. Hand in a dummy method invocation result you can create via methodOn(Class, Object...) or DummyInvocationUtils.methodOn(Class, Object...).

Parameters:
invocationValue -
Returns:

methodOn

public static <T> T methodOn(Class<T> controller,
                             Object... parameters)
Wrapper for DummyInvocationUtils.methodOn(Class, Object...) to be available in case you work with static imports of ControllerLinkBuilder.

Parameters:
controller - must not be null.
parameters - parameters to extend template variables in the type level mapping.
Returns:

getThis

protected ControllerLinkBuilder getThis()
Description copied from class: LinkBuilderSupport
Returns the current concrete instance.

Specified by:
getThis in class LinkBuilderSupport<ControllerLinkBuilder>
Returns:

createNewInstance

protected ControllerLinkBuilder createNewInstance(UriComponentsBuilder builder)
Description copied from class: LinkBuilderSupport
Creates a new instance of the sub-class.

Specified by:
createNewInstance in class LinkBuilderSupport<ControllerLinkBuilder>
Parameters:
builder - will never be null.
Returns:

toUriComponentsBuilder

public UriComponentsBuilder toUriComponentsBuilder()
Returns a UriComponentsBuilder to continue to build the already built URI in a more fine grained way.

Returns:

Spring Hateoas

Copyright © 2012-2014-2014 Pivotal, Inc.. All Rights Reserved.