Java SpringHateOAS:如何通过添加自定义链接来调整现有的CollectionModel?

Java SpringHateOAS:如何通过添加自定义链接来调整现有的CollectionModel?,java,spring,spring-data-rest,spring-hateoas,Java,Spring,Spring Data Rest,Spring Hateoas,在我的Spring Boot项目中,我有两个实体,如卖方和买方。通过扩展crudepository,我使SpringDataREST能够自动为它们中的每一个创建一个CollectionModel,可以通过相应的端点(如/sellers和/bullers)访问。现在,我想通过编写RepresentationModelProcessor这样的RepresentationModelProcessor为Buyer添加一个自定义“过滤器”-链接到CollectionModel: @组件 公共类BuyerC

在我的Spring Boot项目中,我有两个实体,如
卖方
买方
。通过扩展
crudepository
,我使SpringDataREST能够自动为它们中的每一个创建一个
CollectionModel
,可以通过相应的端点(如
/sellers
/bullers
)访问。现在,我想通过编写
RepresentationModelProcessor
这样的
RepresentationModelProcessor
Buyer
添加一个自定义“过滤器”-链接到
CollectionModel

@组件
公共类BuyerCollectionModelProcessor实现
RepresentationModelProcessor{
@凌驾
公共集合模型流程(集合模型){
//这里我们添加了一个链接,指向BuyerController类中的某个filter()方法
返回model.add(linkTo(methodOn)(BuyerController.class)
.filterBy(可选.empty(),可选.empty())
.withRel(“过滤器”);
}
}
它与预期的
/bullers
一起工作,现在包括“过滤器”链接:

“\u链接”:{
“自我”:{
“href”:”http://localhost:8080/buyers"
},
“过滤器”:{
“href”:”http://localhost:8080/buyers/filterBy{?城市,时代}“,
“模板化”:正确
}
}
然而,问题是,
/sellers
现在也有买家“筛选”链接:

“\u链接”:{
“自我”:{
“href”:”http://localhost:8080/sellers"
},
“过滤器”:{
“href”:”http://localhost:8080/buyers/filterBy{?城市,时代}“,
“模板化”:正确
}
}
如果我决定以类似的方式向
/sellers
添加自定义链接,那么
/sellers
/bullers
将分别具有两个链接。如何修复该链接并分离自定义链接,以便它们仅包含在其相应实体的
CollectionModel