Spring Hateoas

org.springframework.hateoas.mvc
Class UriComponentsLinkBuilder<T extends LinkBuilder>

java.lang.Object
  extended by org.springframework.hateoas.mvc.UriComponentsLinkBuilder<T>
All Implemented Interfaces:
LinkBuilder
Direct Known Subclasses:
ControllerLinkBuilder, JaxRsLinkBuilder

public abstract class UriComponentsLinkBuilder<T extends LinkBuilder>
extends Object
implements LinkBuilder

Base class to implement LinkBuilders based on a Spring MVC UriComponentsBuilder.

Author:
Ricardo Gladwell, Oliver Gierke

Constructor Summary
UriComponentsLinkBuilder(UriComponentsBuilder builder)
          Creates a new UriComponentsLinkBuilder using the given UriComponentsBuilder.
 
Method Summary
protected abstract  T createNewInstance(UriComponentsBuilder builder)
          Creates a new instance of the sub-class.
protected abstract  T getThis()
          Returns the current concrete instance.
 LinkBuilder slash(Identifiable<?> identifyable)
          Adds the given Identifiable's id as sub-resource.
 T slash(Object object)
          Adds the given object's String representation as sub-resource to the current URI.
 String toString()
           
 URI toUri()
          Creates a URI of the link built by the current builder instance.
 Link withRel(String rel)
          Creates the Link built by the current builder instance with the given rel.
 Link withSelfRel()
          Creates the Link built by the current builder instance with the default self rel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UriComponentsLinkBuilder

public UriComponentsLinkBuilder(UriComponentsBuilder builder)
Creates a new UriComponentsLinkBuilder using the given UriComponentsBuilder.

Parameters:
builder - must not be null.
Method Detail

slash

public T slash(Object object)
Description copied from interface: LinkBuilder
Adds the given object's String representation as sub-resource to the current URI.

Specified by:
slash in interface LinkBuilder
Returns:

slash

public LinkBuilder slash(Identifiable<?> identifyable)
Description copied from interface: LinkBuilder
Adds the given Identifiable's id as sub-resource. Will simply return the LinkBuilder as is if the given entity is null.

Specified by:
slash in interface LinkBuilder
Returns:

toUri

public URI toUri()
Description copied from interface: LinkBuilder
Creates a URI of the link built by the current builder instance.

Specified by:
toUri in interface LinkBuilder
Returns:

withRel

public Link withRel(String rel)
Description copied from interface: LinkBuilder
Creates the Link built by the current builder instance with the given rel.

Specified by:
withRel in interface LinkBuilder
Parameters:
rel - must not be null or empty.
Returns:

withSelfRel

public Link withSelfRel()
Description copied from interface: LinkBuilder
Creates the Link built by the current builder instance with the default self rel.

Specified by:
withSelfRel in interface LinkBuilder
Returns:
See Also:
Link.REL_SELF

toString

public String toString()
Overrides:
toString in class Object

getThis

protected abstract T getThis()
Returns the current concrete instance.

Returns:

createNewInstance

protected abstract T createNewInstance(UriComponentsBuilder builder)
Creates a new instance of the sub-class.

Parameters:
builder - will never be null.
Returns:

Spring Hateoas

Copyright © 2012 SpringSource, a division of VMware. All Rights Reserved.