Spring Data ReST ref link omission when null or empty

倾然丶 夕夏残阳落幕 提交于 2019-12-01 12:57:33

Generally speaking you should be able to remove links by just calling Resource.getLinks() and mess with the List returned. If you think a Resource.removeLink(String rel) makes sense, feel free to create a ticket for that.

However, I'd argue the links pointing to empty resources makes sense as the presence of links has an important role in telling the client that there's a related resource it can interact with. In other words: if the link is not available, how would the client find out about the possibility to assign a related resource, or to add an element to the currently empty collection.

Links are not only representing the current state of the resource but affordances to what the client shall/can do next. Take the payment link in the RESTBucks project for example. It's only present, if no payment has been placed yet. Once done, the link even disappears. That's actually the opposite of what you're shooting for :).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!