spring-hateoas icon indicating copy to clipboard operation
spring-hateoas copied to clipboard

Fluent Api for adding links to a PagedModel return a CollectionModel

Open Patouche opened this issue 5 years ago • 3 comments
trafficstars

Hi the spring team,

When we use the add method on a PagedModel, this method will return a CollectionModel and we "loose" the type PagedModel type. In fact, if we want to retrieve it, we can cast the CollectionModel into a PagedModel.

This can be achieve creating a new abstract class AbstractCollectionModel<S extends AbstractCollectionModel<S, T>, T> which will extends RepresentationModel<S>. After that, CollectionModel<T> will be empty and will extends AbstractCollectionModel<CollectionModel<T>, T> and it will be almost the same for PagedModel

I can submit a PR if you want with this changes.

Patouche avatar May 29 '20 05:05 Patouche