Package it.davidepedone.scp.hateoas
Class SlicedModel<T>
- java.lang.Object
-
- org.springframework.hateoas.RepresentationModel<org.springframework.hateoas.CollectionModel<T>>
-
- org.springframework.hateoas.CollectionModel<T>
-
- it.davidepedone.scp.hateoas.SlicedModel<T>
-
- All Implemented Interfaces:
Iterable<T>
public class SlicedModel<T> extends org.springframework.hateoas.CollectionModel<T>DTO to implement binding response representations of sliceable collections.- Since:
- 1.0
- Author:
- Davide Pedone
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSlicedModel.SliceMetadata
-
Constructor Summary
Constructors Modifier Constructor Description protectedSlicedModel()Default constructor to allow instantiation by reflection.protectedSlicedModel(Collection<T> content, SlicedModel.SliceMetadata metadata, Iterable<org.springframework.hateoas.Link> links)protectedSlicedModel(Collection<T> content, SlicedModel.SliceMetadata metadata, org.springframework.hateoas.Link... links)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> SlicedModel<T>empty()Creates a new empty collection model.static <T> SlicedModel<T>empty(Iterable<org.springframework.hateoas.Link> links)Creates a new empty collection model with the given links.SlicedModel.SliceMetadatagetMetadata()Returns the pagination metadata.org.springframework.hateoas.LinkgetNextLink()Returns the Link pointing to the next page (if set).org.springframework.hateoas.LinkgetSelfLink()Returns the Link pointing to the current page (if set).Iterator<T>iterator()static <T> SlicedModel<T>of(Collection<T> content, SlicedModel.SliceMetadata metadata)Creates a newSlicedModelwith the given content and metadata.static <T> SlicedModel<T>of(Collection<T> content, SlicedModel.SliceMetadata metadata, Iterable<org.springframework.hateoas.Link> links)Creates a newSlicedModelwith the given content, metadata andLinks.-
Methods inherited from class org.springframework.hateoas.CollectionModel
empty, equals, getContent, hashCode, of, of, of, toString, wrap
-
Methods inherited from class org.springframework.hateoas.RepresentationModel
add, add, add, addAllIf, addIf, getLink, getLink, getLinks, getLinks, getLinks, getRequiredLink, getRequiredLink, hasLink, hasLink, hasLinks, of, of, removeLinks
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
SlicedModel
protected SlicedModel()
Default constructor to allow instantiation by reflection.
-
SlicedModel
protected SlicedModel(Collection<T> content, SlicedModel.SliceMetadata metadata, org.springframework.hateoas.Link... links)
- Parameters:
content- must not be null.metadata- the metadata to add to theSlicedModel.links- the links to add to theSlicedModel.
-
SlicedModel
protected SlicedModel(Collection<T> content, SlicedModel.SliceMetadata metadata, Iterable<org.springframework.hateoas.Link> links)
- Parameters:
content- must not be null.metadata- the metadata to add to theSlicedModel.links- the links to add to theSlicedModel.
-
-
Method Detail
-
empty
public static <T> SlicedModel<T> empty()
Creates a new empty collection model.- Type Parameters:
T- Entity- Returns:
- empty SlicedModel
- Since:
- 1.0
-
empty
public static <T> SlicedModel<T> empty(Iterable<org.springframework.hateoas.Link> links)
Creates a new empty collection model with the given links.- Type Parameters:
T- Entity- Parameters:
links- must not be null.- Returns:
- empty SlicedModel
- Since:
- 1.0
-
of
public static <T> SlicedModel<T> of(Collection<T> content, SlicedModel.SliceMetadata metadata)
Creates a newSlicedModelwith the given content and metadata.- Type Parameters:
T- Entity class- Parameters:
content- must not be null.metadata- the metadata to add to theSlicedModel.- Returns:
- a new
SlicedModelwith the given content and metadata - Since:
- 1.0
-
of
public static <T> SlicedModel<T> of(Collection<T> content, SlicedModel.SliceMetadata metadata, Iterable<org.springframework.hateoas.Link> links)
Creates a newSlicedModelwith the given content, metadata andLinks.- Type Parameters:
T- Entity class- Parameters:
content- must not be null.metadata- the metadata to add to theSlicedModel.links- the links to add to theSlicedModel.- Returns:
- a new
SlicedModelwith the given content and metadata and Link
-
getMetadata
public SlicedModel.SliceMetadata getMetadata()
Returns the pagination metadata.- Returns:
- the metadata
-
getNextLink
public org.springframework.hateoas.Link getNextLink()
Returns the Link pointing to the next page (if set).- Returns:
- the Link pointing to the next page
-
getSelfLink
public org.springframework.hateoas.Link getSelfLink()
Returns the Link pointing to the current page (if set).- Returns:
- the Link pointing to the current page
-
-