#124 - Fixed mapping annotations in ResourceSupport types.

Added @XmlAnyElement to Resource and moved annotations to accessors to avoid name clashes when overriding them using Jackson mixins.
This commit is contained in:
Oliver Gierke
2013-12-16 15:12:38 +01:00
parent 27069b82d6
commit fac6bbb2cc
5 changed files with 51 additions and 15 deletions

View File

@@ -34,8 +34,6 @@ public class PagedResources<T> extends Resources<T> {
public static PagedResources<?> NO_PAGE = new PagedResources<Object>();
@org.codehaus.jackson.annotate.JsonProperty("page")//
@com.fasterxml.jackson.annotation.JsonProperty("page")//
private PageMetadata metadata;
/**
@@ -73,6 +71,8 @@ public class PagedResources<T> extends Resources<T> {
*
* @return the metadata
*/
@org.codehaus.jackson.annotate.JsonProperty("page")
@com.fasterxml.jackson.annotation.JsonProperty("page")
public PageMetadata getMetadata() {
return metadata;
}

View File

@@ -17,6 +17,7 @@ package org.springframework.hateoas;
import java.util.Arrays;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.springframework.util.Assert;
@@ -29,8 +30,6 @@ import org.springframework.util.Assert;
@XmlRootElement
public class Resource<T> extends ResourceSupport {
@org.codehaus.jackson.annotate.JsonUnwrapped
@com.fasterxml.jackson.annotation.JsonUnwrapped
private final T content;
/**
@@ -68,6 +67,9 @@ public class Resource<T> extends ResourceSupport {
*
* @return the content
*/
@org.codehaus.jackson.annotate.JsonUnwrapped
@com.fasterxml.jackson.annotation.JsonUnwrapped
@XmlAnyElement
public T getContent() {
return content;
}

View File

@@ -30,9 +30,6 @@ import org.springframework.util.Assert;
*/
public class ResourceSupport implements Identifiable<Link> {
@XmlElement(name = "link", namespace = Link.ATOM_NAMESPACE)
@org.codehaus.jackson.annotate.JsonProperty("links")
@com.fasterxml.jackson.annotation.JsonProperty("links")
private final List<Link> links;
public ResourceSupport() {
@@ -94,6 +91,9 @@ public class ResourceSupport implements Identifiable<Link> {
*
* @return
*/
@XmlElement(name = "link", namespace = Link.ATOM_NAMESPACE)
@org.codehaus.jackson.annotate.JsonProperty("links")
@com.fasterxml.jackson.annotation.JsonProperty("links")
public List<Link> getLinks() {
return Collections.unmodifiableList(links);
}

View File

@@ -35,10 +35,6 @@ import org.springframework.util.Assert;
@XmlRootElement(name = "entities")
public class Resources<T> extends ResourceSupport implements Iterable<T> {
@XmlAnyElement
@XmlElementWrapper
@org.codehaus.jackson.annotate.JsonProperty("content")
@com.fasterxml.jackson.annotation.JsonProperty("content")
private final Collection<T> content;
/**
@@ -100,6 +96,10 @@ public class Resources<T> extends ResourceSupport implements Iterable<T> {
*
* @return the content will never be {@literal null}.
*/
@XmlAnyElement
@XmlElementWrapper
@org.codehaus.jackson.annotate.JsonProperty("content")
@com.fasterxml.jackson.annotation.JsonProperty("content")
public Collection<T> getContent() {
return Collections.unmodifiableCollection(content);
}