spring-projects / spring-hateoas

Spring HATEOAS - Library to support implementing representations for hyper-text driven REST web services.
https://spring.io/projects/spring-hateoas
Apache License 2.0
1.04k stars 477 forks source link

Fluent Api for adding links to a PagedModel return a CollectionModel #1300

Open Patouche opened 4 years ago

Patouche commented 4 years ago

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.

gregturn commented 4 years ago

Actually I'd like to see that, if it isn't too much effort on your end.

Patouche commented 4 years ago

Hello,

I've started working on it. It's a little bit harder than I was thinking at first with the Jackson Serializer/Deserialiser.

I will submit this PR when It will be ready.

stephaneeybert commented 4 months ago

Seeing this old issue still opened I now wonder if the spring-hateoas project is still alive ?