Spring Hateoas

org.springframework.hateoas.mvc
Class ControllerLinkBuilderFactory

java.lang.Object
  extended by org.springframework.hateoas.mvc.ControllerLinkBuilderFactory
All Implemented Interfaces:
LinkBuilderFactory<ControllerLinkBuilder>, MethodLinkBuilderFactory<ControllerLinkBuilder>

public class ControllerLinkBuilderFactory
extends Object
implements MethodLinkBuilderFactory<ControllerLinkBuilder>

Factory for LinkBuilderSupport instances based on the request mapping annotated on the given controller.

Author:
Ricardo Gladwell, Oliver Gierke, Dietrich Schulten, Kamill Sokol

Constructor Summary
ControllerLinkBuilderFactory()
           
 
Method Summary
protected  UriComponentsBuilder applyUriComponentsContributer(UriComponentsBuilder builder, DummyInvocationUtils.MethodInvocation invocation)
          Applies the configured UriComponentsContributors to the given UriComponentsBuilder.
 ControllerLinkBuilder linkTo(Class<?> controller)
          Creates a new LinkBuilder with a base of the mapping annotated to the given target clas (controller, service, etc.).
 ControllerLinkBuilder linkTo(Class<?> controller, Method method, Object... parameters)
          Returns a LinkBuilder pointing to the URI mapped to the given Method assuming it was invoked on an object of the given type.
 ControllerLinkBuilder linkTo(Class<?> controller, Object... parameters)
          Creates a new LinkBuilder with a base of the mapping annotated to the given target class (controller, service, etc.).
 ControllerLinkBuilder linkTo(Method method, Object... parameters)
          Returns a LinkBuilder pointing to the URI mapped to the given Method and expanding this mapping using the given parameters.
 ControllerLinkBuilder linkTo(Object invocationValue)
          Returns a LinkBuilder pointing to the URI mapped to the method the result is handed into this method.
 void setUriComponentsContributors(List<? extends UriComponentsContributor> uriComponentsContributors)
          Configures the UriComponentsContributor to be used when building Link instances from method invocations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControllerLinkBuilderFactory

public ControllerLinkBuilderFactory()
Method Detail

setUriComponentsContributors

public void setUriComponentsContributors(List<? extends UriComponentsContributor> uriComponentsContributors)
Configures the UriComponentsContributor to be used when building Link instances from method invocations.

Parameters:
uriComponentsContributors - the uriComponentsContributors to set
See Also:
linkTo(Object)

linkTo

public ControllerLinkBuilder linkTo(Class<?> controller)
Description copied from interface: LinkBuilderFactory
Creates a new LinkBuilder with a base of the mapping annotated to the given target clas (controller, service, etc.).

Specified by:
linkTo in interface LinkBuilderFactory<ControllerLinkBuilder>
Parameters:
controller - must not be null.
Returns:

linkTo

public ControllerLinkBuilder linkTo(Class<?> controller,
                                    Object... parameters)
Description copied from interface: LinkBuilderFactory
Creates a new LinkBuilder with a base of the mapping annotated to the given target class (controller, service, etc.). The additional parameters are used to fill up potentially available path variables in the class scope request mapping.

Specified by:
linkTo in interface LinkBuilderFactory<ControllerLinkBuilder>
Parameters:
controller - must not be null.
parameters - must not be null.
Returns:

linkTo

public ControllerLinkBuilder linkTo(Class<?> controller,
                                    Method method,
                                    Object... parameters)
Description copied from interface: MethodLinkBuilderFactory
Returns a LinkBuilder pointing to the URI mapped to the given Method assuming it was invoked on an object of the given type.

Specified by:
linkTo in interface MethodLinkBuilderFactory<ControllerLinkBuilder>
Parameters:
controller - must not be null.
method - must not be null.
Returns:

linkTo

public ControllerLinkBuilder linkTo(Object invocationValue)
Description copied from interface: MethodLinkBuilderFactory
Returns a LinkBuilder pointing to the URI mapped to the method the result is handed into this method. Use DummyInvocationUtils.methodOn(Class, Object...) to obtain a dummy instance of a controller to record a dummy method invocation on. See ControllerLinkBuilder.linkTo(Object) for an example.

Specified by:
linkTo in interface MethodLinkBuilderFactory<ControllerLinkBuilder>
Parameters:
invocationValue - must not be null.
Returns:
See Also:
ControllerLinkBuilder.linkTo(Object)

linkTo

public ControllerLinkBuilder linkTo(Method method,
                                    Object... parameters)
Description copied from interface: MethodLinkBuilderFactory
Returns a LinkBuilder pointing to the URI mapped to the given Method and expanding this mapping using the given parameters.

Specified by:
linkTo in interface MethodLinkBuilderFactory<ControllerLinkBuilder>
Parameters:
method - must not be null.
Returns:

applyUriComponentsContributer

protected UriComponentsBuilder applyUriComponentsContributer(UriComponentsBuilder builder,
                                                             DummyInvocationUtils.MethodInvocation invocation)
Applies the configured UriComponentsContributors to the given UriComponentsBuilder.

Parameters:
builder - will never be null.
invocation - will never be null.
Returns:

Spring Hateoas

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