-
Notifications
You must be signed in to change notification settings - Fork 471
Provide link builder DSL to write idiomatic Kotlin code #715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide link builder DSL to write idiomatic Kotlin code #715
Conversation
Looks most exciting. Tell me, could you also add test cases for the new Affordances API? I would like to know we have solid support for that as well. |
@gregturn Sure! |
I'm wondering if we shouldn't turn |
|
@gregturn It's OK for me, thanks for the suggestion! |
@gregturn What do you think about these?
and
|
@sdeleuze I would certainly appreciate your inputs on this endeavor. While familiar with Kotlin, my knowledge is probably over a year old and not detailed. |
What about adding these 2 extensions: |
@rolandKulcsar Could you please detail what other parts of the DSL you would keep in addition to these 2 ones ? |
@sdeleuze I was thinking of those things that are in my #715 (comment) and #715 (comment) comment. |
I should have done this sooner, but linked is an example Spring MVC controller that has multiple methods combined with usage of the Affordances API. I would seek a Kotlin-based variant that presumably is much slicker. |
@rolandKulcsar If you are able to add operations for building affordances, then that might get us in a position to merge your PR. |
bacba91
to
1d967bb
Compare
Happy New Year to everyone! 🥂 I added support to the Affordances API. Example 4
Example 5
|
Woot @rolandKulcsar! This is a good start for a New Year. I am eager to look into this tomorrow when I resume working. |
My attempt to read this PR is tricky. If you could rebase against master, it might slim it down to just your code. |
9468a9f
to
8bb6c78
Compare
8bb6c78
to
5044922
Compare
I rebased against master and squashed the commits. |
* Provide a LinkBuilderDsl for help create links. * Provider an AffordanceBuilderDsl to help create affordances.
Resolved via 9c5d10a. Thanks again @rolandKulcsar! |
Hi Spring and Kotlin fans,
I want to share with you my link builder extensions to be able to write idiomatic Kotlin code with Spring HATEOAS.
Updated at Jan 1 2019
We have the following resources
and controller
Example 1
With link builder extensions to create a self link you can simply write that
Java equivalent
Kotlin equivalent without extensions
Example 2
With link builder extensions to create and add self, products links to CustomerResource you can simply write that
Java equivalent
Kotlin equivalent without extensions
Example 3
To create and add self, products links to a wrapped domain object you can simply write that
Example 4
Creates affordance to a controller method:
Example 5
Creates link with affordances:
Restrictions:
You have to make open your resource classes (or use the kotlin allopen plugin) because of cglib proxy issues.