3939import org .springframework .hateoas .server .RepresentationModelAssembler ;
4040import org .springframework .hateoas .server .core .EmbeddedWrapper ;
4141import org .springframework .hateoas .server .core .EmbeddedWrappers ;
42+ import org .springframework .lang .CheckReturnValue ;
4243import org .springframework .util .Assert ;
4344import org .springframework .web .servlet .support .ServletUriComponentsBuilder ;
4445import org .springframework .web .util .UriComponents ;
@@ -100,6 +101,7 @@ public void setForceFirstRel(boolean forceFirstRel) {
100101 * @return will never be {@literal null}.
101102 * @since 3.1
102103 */
104+ @ CheckReturnValue
103105 public SlicedResourcesAssembler <T > withParameter (@ Nullable MethodParameter parameter ) {
104106 return new SlicedResourcesAssembler <>(pageableResolver , baseUri , parameter );
105107 }
@@ -116,7 +118,7 @@ public SlicedModel<EntityModel<T>> toModel(Slice<T> entity) {
116118 *
117119 * @param slice must not be {@literal null}.
118120 * @param selfLink must not be {@literal null}.
119- * @return
121+ * @return a {@link SlicedModel}.
120122 */
121123 public SlicedModel <EntityModel <T >> toModel (Slice <T > slice , Link selfLink ) {
122124 return toModel (slice , EntityModel ::of , selfLink );
@@ -128,7 +130,7 @@ public SlicedModel<EntityModel<T>> toModel(Slice<T> slice, Link selfLink) {
128130 *
129131 * @param slice must not be {@literal null}.
130132 * @param assembler must not be {@literal null}.
131- * @return
133+ * @return a {@link SlicedModel}.
132134 */
133135 public <R extends RepresentationModel <?>> SlicedModel <R > toModel (Slice <T > slice ,
134136 RepresentationModelAssembler <T , R > assembler ) {
@@ -143,11 +145,13 @@ public <R extends RepresentationModel<?>> SlicedModel<R> toModel(Slice<T> slice,
143145 * @param slice must not be {@literal null}.
144146 * @param assembler must not be {@literal null}.
145147 * @param link must not be {@literal null}.
146- * @return a {@link SlicedModel} must not be {@literal null} .
148+ * @return a {@link SlicedModel}.
147149 */
148150 public <R extends RepresentationModel <?>> SlicedModel <R > toModel (Slice <T > slice ,
149151 RepresentationModelAssembler <T , R > assembler , Link link ) {
152+
150153 Assert .notNull (link , "Link must not be null" );
154+
151155 return createModel (slice , assembler , link );
152156 }
153157
@@ -156,7 +160,7 @@ public <R extends RepresentationModel<?>> SlicedModel<R> toModel(Slice<T> slice,
156160 *
157161 * @param slice must not be {@literal null}, content must be empty.
158162 * @param type must not be {@literal null}.
159- * @return
163+ * @return an empty {@link SlicedModel}.
160164 */
161165 public SlicedModel <?> toEmptyModel (Slice <?> slice , Class <?> type ) {
162166 return toEmptyModel (slice , type , (Link ) null );
@@ -168,7 +172,7 @@ public SlicedModel<?> toEmptyModel(Slice<?> slice, Class<?> type) {
168172 * @param slice must not be {@literal null}, content must be empty.
169173 * @param type must not be {@literal null}.
170174 * @param link can be {@literal null}.
171- * @return a {@link SlicedModel} must not be {@literal null }.
175+ * @return an empty {@link SlicedModel}.
172176 */
173177 public SlicedModel <?> toEmptyModel (Slice <?> slice , Class <?> type , @ Nullable Link link ) {
174178
@@ -187,7 +191,6 @@ public SlicedModel<?> toEmptyModel(Slice<?> slice, Class<?> type, @Nullable Link
187191
188192 @ Deprecated
189193 public SlicedModel <?> toEmptyModel (Slice <?> slice , Class <?> type , Optional <Link > link ) {
190- Assert .notNull (link , "Link must not be null" );
191194 return toEmptyModel (slice , type , link .orElse (null ));
192195 }
193196
@@ -201,6 +204,7 @@ public SlicedModel<?> toEmptyModel(Slice<?> slice, Class<?> type, Optional<Link>
201204 */
202205 protected <R extends RepresentationModel <?>, S > SlicedModel <R > createSlicedModel (List <R > resources ,
203206 SliceMetadata metadata , Slice <S > slice ) {
207+
204208 Assert .notNull (resources , "Content resources must not be null" );
205209 Assert .notNull (metadata , "SliceMetadata must not be null" );
206210 Assert .notNull (slice , "Slice must not be null" );
@@ -210,6 +214,7 @@ protected <R extends RepresentationModel<?>, S> SlicedModel<R> createSlicedModel
210214
211215 private <S , R extends RepresentationModel <?>> SlicedModel <R > createModel (Slice <S > slice ,
212216 RepresentationModelAssembler <S , R > assembler , @ Nullable Link link ) {
217+
213218 Assert .notNull (slice , "Slice must not be null" );
214219 Assert .notNull (assembler , "ResourceAssembler must not be null" );
215220
@@ -227,7 +232,6 @@ private <S, R extends RepresentationModel<?>> SlicedModel<R> createModel(Slice<S
227232 private <R > SlicedModel <R > addPaginationLinks (SlicedModel <R > resources , Slice <?> slice , @ Nullable Link link ) {
228233
229234 UriTemplate base = getUriTemplate (link );
230-
231235 boolean isNavigable = slice .hasPrevious () || slice .hasNext ();
232236
233237 if (isNavigable || forceFirstRel ) {
0 commit comments