diff --git a/basics/README.adoc b/basics/README.adoc index 9e8f576..3da2745 100644 --- a/basics/README.adoc +++ b/basics/README.adoc @@ -157,23 +157,23 @@ The collection's route is shown below: ---- /** * Look up all employees, and transform them into a REST collection resource using - * {@link EmployeeResourceAssembler#toResources(Iterable)}. Then return them through + * {@link EmployeeResourceAssembler#toCollectionModel(Iterable)}. Then return them through * Spring Web's {@link ResponseEntity} fluent API. */ @GetMapping("/employees") -public ResponseEntity>> findAll() { +public ResponseEntity>> findAll() { return ResponseEntity.ok( - assembler.toResources(repository.findAll())); + assembler.toCollectionModel(repository.findAll())); } ---- -It uses the `EmployeeResourceAssembler` and it's `toResources(Iterable)` method to turn a collection of -`Employee` objects into a `Resources>`. +It uses the `EmployeeResourceAssembler` and it's `toCollectionModel(Iterable)` method to turn a collection of +`Employee` objects into a `CollectionModel>`. -NOTE: `Resources` is Spring HATEOAS's vendor neutral representation of a collection. It has it's +NOTE: `CollectionModel` is Spring HATEOAS's vendor neutral representation of a collection. It has it's own set of links, separate from the links of each member of the collection. That's why the whole -structure is `Resources>` and not `Resources`. +structure is `CollectionModel>` and not `CollectionModel`. To build a single resource, the `/employees/{id}` route is shown below: @@ -181,27 +181,27 @@ To build a single resource, the `/employees/{id}` route is shown below: ---- /** * Look up a single {@link Employee} and transform it into a REST resource using - * {@link EmployeeResourceAssembler#toResource(Object)}. Then return it through + * {@link EmployeeResourceAssembler#toEntityModel(Object)}. Then return it through * Spring Web's {@link ResponseEntity} fluent API. * * @param id */ @GetMapping("/employees/{id}") -public ResponseEntity> findOne(@PathVariable long id) { +public ResponseEntity> findOne(@PathVariable long id) { return ResponseEntity.ok( - assembler.toResource(repository.findOne(id))); + assembler.toEntityModel(repository.findOne(id))); } ---- -Again, the `EmployeeResourceAssembler` is used to convert a single `Employee` into a `Resource` -through its `toResource(Employee)` method. +Again, the `EmployeeResourceAssembler` is used to convert a single `Employee` into a `EntityModel` +through its `toEntityModel(Employee)` method. == Customizing the Output What's not shown in this example is that the `EmployeeResourceAssembler` comes with overrides. * `setBasePath(/* base */)` would inject a prefix into every link built in the hypermedia. -* `addLinks(Resource)` and `addLinks(Resources)` allows you to override/augment the default links assigned to every resource. +* `addLinks(EntityModel)` and `addLinks(CollectionModel)` allows you to override/augment the default links assigned to every resource. * `getCollectionLinkBuilder()` lets you override the convention of how the whole route is built up. == Testing Hypermedia