#132 - Added guard to Resource to shield it from being used with Collection content.

Fixed ticket links in Jackson2HalIntegrationTests.
This commit is contained in:
Oliver Gierke
2013-12-29 16:01:43 +01:00
parent 88da0672ab
commit 3b41fc9149
3 changed files with 13 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
package org.springframework.hateoas;
import java.util.Arrays;
import java.util.Collection;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlRootElement;
@@ -58,6 +59,7 @@ public class Resource<T> extends ResourceSupport {
public Resource(T content, Iterable<Link> links) {
Assert.notNull(content, "Content must not be null!");
Assert.isTrue(!(content instanceof Collection), "Content must not be a collection! Use Resources instead!");
this.content = content;
this.add(links);
}