Spring Hateoas

org.springframework.hateoas
Interface EntityLinks

All Superinterfaces:
org.springframework.plugin.core.Plugin<Class<?>>
All Known Implementing Classes:
AbstractEntityLinks, ControllerEntityLinks, DelegatingEntityLinks

public interface EntityLinks
extends org.springframework.plugin.core.Plugin<Class<?>>

Accessor to links pointing to controllers backing an entity type. The IllegalArgumentException potentially thrown by the declared methods will only appear if the #supports(Class) method has returned false and the method has been invoked anyway, i.e. if #supports(Class) returns true it's safe to invoke the interface methods an the exception will never be thrown.

Author:
Oliver Gierke

Method Summary
 LinkBuilder linkFor(Class<?> type)
          Returns a LinkBuilder able to create links to the controller managing the given entity type.
 LinkBuilder linkFor(Class<?> type, 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.
 LinkBuilder linkForSingleResource(Class<?> type, Object id)
          Returns a LinkBuilder able to create links to the controller managing the given entity type and id.
 LinkBuilder linkForSingleResource(Identifiable<?> entity)
          Returns a LinkBuilder able to create links to the controller managing the given entity.
 Link linkToCollectionResource(Class<?> type)
          Creates a Link pointing to the collection resource of the given type.
 Link linkToSingleResource(Class<?> type, Object id)
          Creates a Link pointing to single resource backing the given entity type and id.
 Link linkToSingleResource(Identifiable<?> entity)
          Creates a Link pointing to single resource backing the given entity.
 
Methods inherited from interface org.springframework.plugin.core.Plugin
supports
 

Method Detail

linkFor

LinkBuilder linkFor(Class<?> type)
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:
type - the entity type to point to, must not be null.
Returns:
the LinkBuilder pointing to the collection resource. Will never be null.
Throws:
IllegalArgumentException - in case the given type is unknown the entity links infrastructure.

linkFor

LinkBuilder linkFor(Class<?> type,
                    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.

Parameters:
type - the entity type to point to, must not be null.
Returns:
the LinkBuilder pointing to the collection resource.
Throws:
IllegalArgumentException - in case the given type is unknown the entity links infrastructure.

linkForSingleResource

LinkBuilder linkForSingleResource(Class<?> type,
                                  Object id)
Returns a LinkBuilder able to create links to the controller managing the given entity type and id. Implementations will know about the URI structure being used to expose single-resource URIs.

Parameters:
type - the entity type to point to, must not be null.
id - the id of the object of the handed type, Identifiables will be unwrapped.
Returns:
the LinkBuilder pointing to the single resource identified by the given type and id. Will never be null.
Throws:
IllegalArgumentException - in case the given type is unknown the entity links infrastructure.

linkForSingleResource

LinkBuilder linkForSingleResource(Identifiable<?> entity)
Returns a LinkBuilder able to create links to the controller managing the given entity.

Parameters:
entity - the entity type to point to, must not be null.
Returns:
the LinkBuilder pointing the given entity. Will never be null.
Throws:
IllegalArgumentException - in case the type of the given entity is unknown the entity links infrastructure.
See Also:
linkForSingleResource(Class, Object)

linkToCollectionResource

Link linkToCollectionResource(Class<?> type)
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:
type - 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.
Throws:
IllegalArgumentException - in case the given type is unknown the entity links infrastructure.

linkToSingleResource

Link linkToSingleResource(Class<?> type,
                          Object id)
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:
type - 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.
Throws:
IllegalArgumentException - in case the given type is unknown the entity links infrastructure.

linkToSingleResource

Link linkToSingleResource(Identifiable<?> entity)
Creates a Link pointing to single resource backing the given entity. 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 resource exposed for the given entity. Will never be null.
Throws:
IllegalArgumentException - in case the type of the given entity is unknown the entity links infrastructure.

Spring Hateoas

Copyright © 2012-2014–2014 Pivotal, Inc.. All rights reserved.