Polished Resources abstraction.

Added correct equals(…)/hashCode() methods to PagedResource, PageMetadata. Polished toString() methods of ResourceSupport, Resource, Resources and PagedResources. Added factory method to PagedResources to easily create a plain instance from a set of entities.
This commit is contained in:
Oliver Gierke
2012-08-23 18:34:21 +02:00
parent 2c5dfc12f6
commit 1bb4669828
4 changed files with 179 additions and 18 deletions

View File

@@ -17,6 +17,8 @@ package org.springframework.hateoas;
import java.util.Arrays;
import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.annotate.JsonUnwrapped;
import org.springframework.util.Assert;
@@ -25,6 +27,7 @@ import org.springframework.util.Assert;
*
* @author Oliver Gierke
*/
@XmlRootElement
public class Resource<T> extends ResourceSupport {
@JsonUnwrapped
@@ -59,6 +62,15 @@ public class Resource<T> extends ResourceSupport {
return content;
}
/*
* (non-Javadoc)
* @see org.springframework.hateoas.ResourceSupport#toString()
*/
@Override
public String toString() {
return String.format("Resource { content: %s, %s }", getContent(), super.toString());
}
/*
* (non-Javadoc)
* @see org.springframework.hateoas.ResourceSupport#equals(java.lang.Object)