diff --git a/src/main/java/org/springframework/hateoas/CollectionModel.java b/src/main/java/org/springframework/hateoas/CollectionModel.java index 651f2d77..08a49db3 100644 --- a/src/main/java/org/springframework/hateoas/CollectionModel.java +++ b/src/main/java/org/springframework/hateoas/CollectionModel.java @@ -60,6 +60,7 @@ public class CollectionModel extends RepresentationModel> protected CollectionModel(Iterable content, Iterable links, @Nullable ResolvableType fallbackType) { Assert.notNull(content, "Content must not be null!"); + Assert.notNull(links, "Links must not be null!"); this.content = new ArrayList<>(); diff --git a/src/main/java/org/springframework/hateoas/PagedModel.java b/src/main/java/org/springframework/hateoas/PagedModel.java index acb15c36..6b3a0707 100644 --- a/src/main/java/org/springframework/hateoas/PagedModel.java +++ b/src/main/java/org/springframework/hateoas/PagedModel.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Objects; import java.util.Optional; @@ -237,7 +238,7 @@ public class PagedModel extends CollectionModel { * * @param content must not be {@literal null}. * @param metadata can be {@literal null}. - * @param links + * @return will never be {@literal null}. */ public static PagedModel of(Collection content, @Nullable PageMetadata metadata) { return new PagedModel<>(content, metadata); @@ -248,10 +249,11 @@ public class PagedModel extends CollectionModel { * * @param content must not be {@literal null}. * @param metadata can be {@literal null}. - * @param links + * @param links must not be {@literal null}. + * @return will never be {@literal null}. */ public static PagedModel of(Collection content, @Nullable PageMetadata metadata, Link... links) { - return new PagedModel<>(content, metadata, Arrays.asList(links)); + return new PagedModel<>(content, metadata, List.of(links)); } /** @@ -259,7 +261,7 @@ public class PagedModel extends CollectionModel { * * @param content must not be {@literal null}. * @param metadata can be {@literal null}. - * @param links + * @param links must not be {@literal null}. */ public static PagedModel of(Collection content, @Nullable PageMetadata metadata, Iterable links) { return new PagedModel<>(content, metadata, links); diff --git a/src/main/java/org/springframework/hateoas/server/EntityLinks.java b/src/main/java/org/springframework/hateoas/server/EntityLinks.java index c3151b81..2b3f5224 100644 --- a/src/main/java/org/springframework/hateoas/server/EntityLinks.java +++ b/src/main/java/org/springframework/hateoas/server/EntityLinks.java @@ -25,8 +25,8 @@ import org.springframework.util.Assert; /** * Accessor to links pointing to controllers backing an entity type. The {@link IllegalArgumentException} potentially - * thrown by the declared methods will only appear if the {@link Plugin#supports(Class)} method has returned - * {@literal false} and the method has been invoked anyway, i.e. if {@link Plugin#supports(Class)} returns + * thrown by the declared methods will only appear if the {@code Plugin#supports(Class)} method has returned + * {@literal false} and the method has been invoked anyway, i.e. if {@code Plugin#supports(Class)} returns * {@literal true} it's safe to invoke the interface methods an the exception will never be thrown. * * @author Oliver Gierke diff --git a/src/main/java/org/springframework/hateoas/server/TypedEntityLinks.java b/src/main/java/org/springframework/hateoas/server/TypedEntityLinks.java index f2f54a92..6133f8cc 100644 --- a/src/main/java/org/springframework/hateoas/server/TypedEntityLinks.java +++ b/src/main/java/org/springframework/hateoas/server/TypedEntityLinks.java @@ -46,7 +46,7 @@ public class TypedEntityLinks { * Returns a {@link LinkBuilder} able to create links to the controller managing the given entity. Implementations * will know about the URI structure being used to expose item-resource URIs. * - * @param type the entity to point to, must not be {@literal null}. + * @param entity the entity to point to, must not be {@literal null}. * @return the {@link LinkBuilder} pointing to the item resource identified by the given entity. Will never be * {@literal null}. * @throws IllegalArgumentException in case the given type is unknown the entity links infrastructure. @@ -59,7 +59,7 @@ public class TypedEntityLinks { * Creates a {@link Link} pointing to item resource backing the given entity. The relation type of the link will be * determined by the implementation class and should be defaulted to {@link IanaLinkRelations#SELF}. * - * @param type the entity to point to, must not be {@literal null}. + * @param entity the entity to point to, must not be {@literal null}. * @return the {@link Link} pointing to the resource exposed for the given entity. Will never be {@literal null}. * @throws IllegalArgumentException in case the given type is unknown the entity links infrastructure. */ @@ -91,7 +91,6 @@ public class TypedEntityLinks { * Creates a {@link Link} pointing to the collection resource of the configured type. The relation type of the link * will be determined by the implementation class and should be defaulted to {@link IanaLinkRelations#SELF}. * - * @param type the entity type to point to, must not be {@literal null}. * @return the {@link Link} pointing to the collection resource exposed for the configured entity type. Will never * be {@literal null}. * @throws IllegalArgumentException in case the given type is unknown the entity links infrastructure. diff --git a/src/main/java/org/springframework/hateoas/server/reactive/SimpleReactiveRepresentationModelAssembler.java b/src/main/java/org/springframework/hateoas/server/reactive/SimpleReactiveRepresentationModelAssembler.java index 66f45d3e..ede741d0 100644 --- a/src/main/java/org/springframework/hateoas/server/reactive/SimpleReactiveRepresentationModelAssembler.java +++ b/src/main/java/org/springframework/hateoas/server/reactive/SimpleReactiveRepresentationModelAssembler.java @@ -36,8 +36,9 @@ public interface SimpleReactiveRepresentationModelAssembler /** * Converts the given entity into a {@link EntityModel} wrapped in a {@link Mono}. * - * @param entity - * @return + * @param entity must not be {@literal null}. + * @param exchange must not be {@literal null}. + * @return will never be {@literal null}. */ @Override default Mono> toModel(T entity, ServerWebExchange exchange) { @@ -49,7 +50,9 @@ public interface SimpleReactiveRepresentationModelAssembler /** * Define links to add to every individual {@link EntityModel}. * - * @param resource + * @param resource must not be {@literal null}. + * @param exchange must not be {@literal null}. + * @return will never be {@literal null}. */ default EntityModel addLinks(EntityModel resource, ServerWebExchange exchange) { return resource; @@ -58,9 +61,9 @@ public interface SimpleReactiveRepresentationModelAssembler /** * Converts all given entities into resources and wraps the collection as a resource as well. * - * @see #toResource(Object, ServerWebExchange) + * @see #toModel(Object, ServerWebExchange) * @param entities must not be {@literal null}. - * @return {@link CollectionModel} containing {@link EntityModel} of {@code T}. + * @return {@link CollectionModel} containing {@link EntityModel} of {@code T}, will never be {@literal null}.. */ default Mono>> toCollectionModel(Flux entities, ServerWebExchange exchange) { @@ -75,7 +78,8 @@ public interface SimpleReactiveRepresentationModelAssembler /** * Define links to add to the {@link CollectionModel} collection. * - * @param resources + * @param resources must not be {@literal null}. + * @return will never be {@literal null}. */ default CollectionModel> addLinks(CollectionModel> resources, ServerWebExchange exchange) {