#831 - Introduce null handling.

This commit is contained in:
Greg Turnquist
2019-03-05 15:52:52 -06:00
parent c4e1bedec8
commit 40250d1738
71 changed files with 520 additions and 216 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.hateoas;
import java.util.Arrays;
import java.util.Collection;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
@@ -55,7 +56,7 @@ public class EntityModel<T> extends RepresentationModel<EntityModel<T>> {
* @param content must not be {@literal null}.
* @param links the links to add to the {@link EntityModel}.
*/
public EntityModel(T content, Iterable<Link> links) {
public EntityModel(@Nullable 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!");
@@ -69,6 +70,7 @@ public class EntityModel<T> extends RepresentationModel<EntityModel<T>> {
* @return the content
*/
@JsonUnwrapped
@Nullable
public T getContent() {
return content;
}