#1241 - Additional factory methods for CollectionModel and PagedModel.
Added overloads of ….empty() to allow adding links right on construction.
This commit is contained in:
@@ -81,11 +81,36 @@ public class CollectionModel<T> extends RepresentationModel<CollectionModel<T>>
|
||||
*
|
||||
* @param <T>
|
||||
* @return
|
||||
* @since 1.1
|
||||
*/
|
||||
public static <T> CollectionModel<T> empty() {
|
||||
return of(Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new empty collection model with the given links.
|
||||
*
|
||||
* @param <T>
|
||||
* @param links must not be {@literal null}.
|
||||
* @return
|
||||
* @since 1.1
|
||||
*/
|
||||
public static <T> CollectionModel<T> empty(Link... links) {
|
||||
return of(Collections.emptyList(), links);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new empty collection model with the given links.
|
||||
*
|
||||
* @param <T>
|
||||
* @param links must not be {@literal null}.
|
||||
* @return
|
||||
* @since 1.1
|
||||
*/
|
||||
public static <T> CollectionModel<T> empty(Iterable<Link> links) {
|
||||
return of(Collections.emptyList(), links);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link CollectionModel} instance with the given content.
|
||||
*
|
||||
|
||||
@@ -83,7 +83,31 @@ public class PagedModel<T> extends CollectionModel<T> {
|
||||
* @since 1.1
|
||||
*/
|
||||
public static <T> PagedModel<T> empty() {
|
||||
return empty(null);
|
||||
return empty(Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty {@link PagedModel} with the given links.
|
||||
*
|
||||
* @param <T>
|
||||
* @param links must not be {@literal null}.
|
||||
* @return
|
||||
* @since 1.1
|
||||
*/
|
||||
public static <T> PagedModel<T> empty(Link... links) {
|
||||
return empty((PageMetadata) null, links);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty {@link PagedModel} with the given links.
|
||||
*
|
||||
* @param <T>
|
||||
* @param links must not be {@literal null}.
|
||||
* @return
|
||||
* @since 1.1
|
||||
*/
|
||||
public static <T> PagedModel<T> empty(Iterable<Link> links) {
|
||||
return empty((PageMetadata) null, links);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +119,33 @@ public class PagedModel<T> extends CollectionModel<T> {
|
||||
* @since 1.1
|
||||
*/
|
||||
public static <T> PagedModel<T> empty(@Nullable PageMetadata metadata) {
|
||||
return of(Collections.emptyList(), metadata);
|
||||
return empty(metadata, Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty {@link PagedModel} with the given {@link PageMetadata} and links.
|
||||
*
|
||||
* @param <T>
|
||||
* @param metadata can be {@literal null}.
|
||||
* @param links must not be {@literal null}.
|
||||
* @return
|
||||
* @since 1.1
|
||||
*/
|
||||
public static <T> PagedModel<T> empty(@Nullable PageMetadata metadata, Link... links) {
|
||||
return empty(Arrays.asList(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty {@link PagedModel} with the given {@link PageMetadata} and links.
|
||||
*
|
||||
* @param <T>
|
||||
* @param metadata can be {@literal null}.
|
||||
* @param links must not be {@literal null}.
|
||||
* @return
|
||||
* @since 1.1
|
||||
*/
|
||||
public static <T> PagedModel<T> empty(@Nullable PageMetadata metadata, Iterable<Link> links) {
|
||||
return of(Collections.emptyList(), metadata, links);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user