Spring Hateoas

org.springframework.hateoas.core
Class LinkBuilderSupport<T extends LinkBuilder>

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

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

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

Author:
Ricardo Gladwell, Oliver Gierke, Kamill Sokol

Constructor Summary
LinkBuilderSupport(UriComponentsBuilder builder)
          Creates a new LinkBuilderSupport 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.
 T 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

LinkBuilderSupport

public LinkBuilderSupport(UriComponentsBuilder builder)
Creates a new LinkBuilderSupport 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. Will unwrap Identifiables to their id value (see Identifiable.getId()).

Specified by:
slash in interface LinkBuilder
Returns:

slash

public T 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-2014–2014 Pivotal, Inc.. All rights reserved.