Spring Hateoas

org.springframework.hateoas.core
Class ControllerEntityLinks

java.lang.Object
  extended by org.springframework.hateoas.core.AbstractEntityLinks
      extended by org.springframework.hateoas.core.ControllerEntityLinks
All Implemented Interfaces:
EntityLinks, org.springframework.plugin.core.Plugin<Class<?>>

public class ControllerEntityLinks
extends AbstractEntityLinks

EntityLinks implementation which assumes a certain URI mapping structure:

  1. A class-level mapping annotation that can contain template variables. The URI needs to expose the collection resource, which means the controller has to expose a handler method mapped to an empty path: e.g. @RequestMapping(method = RequestMethod.GET) in case of a Spring MVC controller.
  2. Individual resources are exposed via a nested mapping consisting of the id of the managed entity, e.g. {@code

    Author:
    Oliver Gierke

    Constructor Summary
    ControllerEntityLinks(Iterable<? extends Class<?>> controllerTypes, LinkBuilderFactory<? extends LinkBuilder> linkBuilderFactory)
              Creates a new ControllerEntityLinks inspecting the configured classes for the given annotation.
     
    Method Summary
     LinkBuilder linkFor(Class<?> entity)
              Returns a LinkBuilder able to create links to the controller managing the given entity type.
     LinkBuilder linkFor(Class<?> entity, Object... parameters)
              Returns a LinkBuilder able to create links to the controller managing the given entity type, unfolding the given parameters into the URI template the backing controller is mapped to.
     Link linkToCollectionResource(Class<?> entity)
              Creates a Link pointing to the collection resource of the given type.
     Link linkToSingleResource(Class<?> entity, Object id)
              Creates a Link pointing to single resource backing the given entity type and id.
     boolean supports(Class<?> delimiter)
               
     
    Methods inherited from class org.springframework.hateoas.core.AbstractEntityLinks
    linkForSingleResource, linkForSingleResource, linkToSingleResource
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    ControllerEntityLinks

    public ControllerEntityLinks(Iterable<? extends Class<?>> controllerTypes,
                                 LinkBuilderFactory<? extends LinkBuilder> linkBuilderFactory)
    Creates a new ControllerEntityLinks inspecting the configured classes for the given annotation.

    Parameters:
    controllerTypes - the controller classes to be inspected.
    linkBuilderFactory - the LinkBuilder to use to create links.
    Method Detail

    linkFor

    public LinkBuilder linkFor(Class<?> entity)
    Description copied from interface: EntityLinks
    Returns a LinkBuilder able to create links to the controller managing the given entity type. Expects a controller being mapped to a fully expanded URI template (i.e. not path variables being used).

    Parameters:
    entity - the entity type to point to, must not be null.
    Returns:
    the LinkBuilder pointing to the collection resource. Will never be null.

    linkFor

    public LinkBuilder linkFor(Class<?> entity,
                               Object... parameters)
    Description copied from interface: EntityLinks
    Returns a LinkBuilder able to create links to the controller managing the given entity type, unfolding the given parameters into the URI template the backing controller is mapped to.

    Parameters:
    entity - the entity type to point to, must not be null.
    Returns:
    the LinkBuilder pointing to the collection resource.

    linkToCollectionResource

    public Link linkToCollectionResource(Class<?> entity)
    Description copied from interface: EntityLinks
    Creates a Link pointing to the collection resource of the given type. The relation type of the link will be determined by the implementation class and should be defaulted to Link.REL_SELF.

    Parameters:
    entity - the entity type to point to, must not be null.
    Returns:
    the Link pointing to the collection resource exposed for the given entity. Will never be null.

    linkToSingleResource

    public Link linkToSingleResource(Class<?> entity,
                                     Object id)
    Description copied from interface: EntityLinks
    Creates a Link pointing to single resource backing the given entity type and id. The relation type of the link will be determined by the implementation class and should be defaulted to Link.REL_SELF.

    Parameters:
    entity - the entity type to point to, must not be null.
    id - the identifier of the entity of the given type
    Returns:
    the Link pointing to the resource exposed for the entity with the given type and id. Will never be null.

    supports

    public boolean supports(Class<?> delimiter)

    Spring Hateoas

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