Java Code Examples for org.springframework.hateoas.CollectionModel#add()

The following examples show how to use org.springframework.hateoas.CollectionModel#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmployeeWithManagerResourceAssembler.java    From spring-hateoas-examples with Apache License 2.0 5 votes vote down vote up
/**
 * Define links to add to the {@link CollectionModel} collection.
 *
 * @param resources
 */
@Override
public void addLinks(CollectionModel<EntityModel<EmployeeWithManager>> resources) {

	resources.add(linkTo(methodOn(EmployeeController.class).findAllDetailedEmployees()).withSelfRel());
	resources.add(linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"));
	resources.add(linkTo(methodOn(ManagerController.class).findAll()).withRel("managers"));
	resources.add(linkTo(methodOn(RootController.class).root()).withRel("root"));
}
 
Example 2
Source File: ManagerRepresentationModelAssembler.java    From spring-hateoas-examples with Apache License 2.0 5 votes vote down vote up
/**
 * Retain default links for the entire collection, but add extra custom links for the {@link Manager} collection.
 *
 * @param resources
 */
@Override
public void addLinks(CollectionModel<EntityModel<Manager>> resources) {

	super.addLinks(resources);

	resources.add(linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"));
	resources.add(linkTo(methodOn(EmployeeController.class).findAllDetailedEmployees()).withRel("detailedEmployees"));
	resources.add(linkTo(methodOn(RootController.class).root()).withRel("root"));
}
 
Example 3
Source File: EmployeeRepresentationModelAssembler.java    From spring-hateoas-examples with Apache License 2.0 5 votes vote down vote up
/**
 * Define links to add to {@link CollectionModel} collection.
 *
 * @param resources
 */
@Override
public void addLinks(CollectionModel<EntityModel<Employee>> resources) {

	super.addLinks(resources);

	resources.add(linkTo(methodOn(EmployeeController.class).findAllDetailedEmployees()).withRel("detailedEmployees"));
	resources.add(linkTo(methodOn(ManagerController.class).findAll()).withRel("managers"));
	resources.add(linkTo(methodOn(RootController.class).root()).withRel("root"));
}