#1352 - Render Map entries once.

Maps, when wrapped inside an EntityModel, were getting double-rendered. Fix it so that they are only rendered once.
This commit is contained in:
Greg L. Turnquist
2020-08-11 13:57:42 -05:00
committed by Oliver Drotbohm
parent b0dbbd56fa
commit 69c81f24e4
3 changed files with 27 additions and 5 deletions

View File

@@ -21,6 +21,8 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -117,7 +119,7 @@ public class EntityModel<T> extends RepresentationModel<EntityModel<T>> {
@JsonUnwrapped
@Nullable
public T getContent() {
return content;
return !Map.class.isInstance(content) ? content : null;
}
// Hacks to allow deserialization into an EntityModel<Map<String, Object>>
@@ -125,7 +127,7 @@ public class EntityModel<T> extends RepresentationModel<EntityModel<T>> {
@Nullable
@JsonAnyGetter
@SuppressWarnings("unchecked")
private Map<String, Object> getMapContent() {
public Map<String, Object> getMapContent() {
return Map.class.isInstance(content) ? (Map<String, Object>) content : null;
}