Spring Hateoas

org.springframework.hateoas
Class Resources<T>

java.lang.Object
  extended by org.springframework.hateoas.ResourceSupport
      extended by org.springframework.hateoas.Resources<T>
All Implemented Interfaces:
Iterable<T>, Identifiable<Link>
Direct Known Subclasses:
PagedResources, ResourcesMixin

public class Resources<T>
extends ResourceSupport
implements Iterable<T>

General helper to easily create a wrapper for a collection of entities.

Author:
Oliver Gierke

Constructor Summary
protected Resources()
          Creates an empty Resources instance.
  Resources(Iterable<T> content, Iterable<Link> links)
          Creates a Resources instance with the given content and Links.
  Resources(Iterable<T> content, Link... links)
          Creates a Resources instance with the given content and Links (optional).
 
Method Summary
 boolean equals(Object obj)
           
 Collection<T> getContent()
          Returns the underlying elements.
 int hashCode()
           
 Iterator<T> iterator()
           
 String toString()
           
static
<T extends Resource<S>,S>
Resources<T>
wrap(Iterable<S> content)
          Creates a new Resources instance by wrapping the given domain class instances into a Resource.
 
Methods inherited from class org.springframework.hateoas.ResourceSupport
add, add, getId, getLink, getLinks, hasLink, hasLinks, removeLinks
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Resources

protected Resources()
Creates an empty Resources instance.


Resources

public Resources(Iterable<T> content,
                 Link... links)
Creates a Resources instance with the given content and Links (optional).

Parameters:
content - must not be null.
links - the links to be added to the Resources.

Resources

public Resources(Iterable<T> content,
                 Iterable<Link> links)
Creates a Resources instance with the given content and Links.

Parameters:
content - must not be null.
links - the links to be added to the Resources.
Method Detail

wrap

public static <T extends Resource<S>,S> Resources<T> wrap(Iterable<S> content)
Creates a new Resources instance by wrapping the given domain class instances into a Resource.

Parameters:
content - must not be null.
Returns:

getContent

public Collection<T> getContent()
Returns the underlying elements.

Returns:
the content will never be null.

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>

toString

public String toString()
Overrides:
toString in class ResourceSupport

equals

public boolean equals(Object obj)
Overrides:
equals in class ResourceSupport

hashCode

public int hashCode()
Overrides:
hashCode in class ResourceSupport

Spring Hateoas

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