DATAREST-622 - Removed unnecessary wrapping of embeddeds.

We now use a plain collection of EmbeddedWrapper instead of a Resources to avoid the links contained in the Resources to potentially cause issues on rendering.
This commit is contained in:
Oliver Gierke
2015-07-21 11:42:14 +02:00
parent de5a98d47b
commit 1e9e3f5635
2 changed files with 5 additions and 10 deletions

View File

@@ -28,8 +28,6 @@ import org.springframework.hateoas.Resources;
import org.springframework.hateoas.core.EmbeddedWrapper;
import org.springframework.util.Assert;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
/**
* A Spring HATEOAS {@link Resource} subclass that holds a reference to the entity's {@link PersistentEntity} metadata.
*
@@ -38,11 +36,10 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped;
*/
public class PersistentEntityResource extends Resource<Object> {
private static final Resources<EmbeddedWrapper> NO_EMBEDDEDS = new Resources<EmbeddedWrapper>(
Collections.<EmbeddedWrapper> emptyList());
private static final Iterable<EmbeddedWrapper> NO_EMBEDDEDS = Collections.emptyList();
private final PersistentEntity<?, ?> entity;
private final Resources<EmbeddedWrapper> embeddeds;
private final Iterable<EmbeddedWrapper> embeddeds;
/**
* Creates a new {@link PersistentEntityResource} for the given {@link PersistentEntity}, content, embedded
@@ -54,7 +51,7 @@ public class PersistentEntityResource extends Resource<Object> {
* @param embeddeds can be {@literal null}.
*/
private PersistentEntityResource(PersistentEntity<?, ?> entity, Object content, Iterable<Link> links,
Resources<EmbeddedWrapper> embeddeds) {
Iterable<EmbeddedWrapper> embeddeds) {
super(content, links);
@@ -87,8 +84,7 @@ public class PersistentEntityResource extends Resource<Object> {
*
* @return the embeddeds
*/
@JsonUnwrapped
public Resources<EmbeddedWrapper> getEmbeddeds() {
public Iterable<EmbeddedWrapper> getEmbeddeds() {
return embeddeds;
}

View File

@@ -43,7 +43,6 @@ import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.UriTemplate;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -172,7 +171,7 @@ public class PersistentEntityJackson2Module extends SimpleModule {
Resource<Object> resourceToRender = new Resource<Object>(resource.getContent(), links) {
@JsonUnwrapped
public Resources<?> getEmbedded() {
public Iterable<?> getEmbedded() {
return resource.getEmbeddeds();
}
};