11package org .baeldung .web .controller ;
22
3- import com .google .common .base .Preconditions ;
3+ import java .util .List ;
4+
5+ import javax .servlet .http .HttpServletResponse ;
6+
47import org .baeldung .persistence .model .Foo ;
58import org .baeldung .persistence .service .IFooService ;
69import org .baeldung .web .exception .MyResourceNotFoundException ;
1417import org .springframework .http .HttpStatus ;
1518import org .springframework .http .MediaType ;
1619import org .springframework .stereotype .Controller ;
17- import org .springframework .web .bind .annotation .*;
20+ import org .springframework .web .bind .annotation .PathVariable ;
21+ import org .springframework .web .bind .annotation .RequestBody ;
22+ import org .springframework .web .bind .annotation .RequestMapping ;
23+ import org .springframework .web .bind .annotation .RequestMethod ;
24+ import org .springframework .web .bind .annotation .RequestParam ;
25+ import org .springframework .web .bind .annotation .ResponseBody ;
26+ import org .springframework .web .bind .annotation .ResponseStatus ;
1827import org .springframework .web .util .UriComponentsBuilder ;
1928
20- import javax .servlet .http .HttpServletResponse ;
21- import java .util .List ;
29+ import com .google .common .base .Preconditions ;
2230
2331@ Controller
2432@ RequestMapping (value = "/foos" )
@@ -81,7 +89,7 @@ public List<Foo> findPaginated(@RequestParam("page") final int page, @RequestPar
8189 @ ResponseBody
8290 public Foo create (@ RequestBody final Foo resource , final HttpServletResponse response ) {
8391 Preconditions .checkNotNull (resource );
84- Foo foo = service .create (resource );
92+ final Foo foo = service .create (resource );
8593 final Long idOfCreatedResource = foo .getId ();
8694
8795 eventPublisher .publishEvent (new ResourceCreatedEvent (this , response , idOfCreatedResource ));
@@ -105,7 +113,7 @@ public void delete(@PathVariable("id") final Long id) {
105113
106114 @ RequestMapping (method = RequestMethod .HEAD )
107115 @ ResponseStatus (HttpStatus .OK )
108- public void head (HttpServletResponse resp ) {
116+ public void head (final HttpServletResponse resp ) {
109117 resp .setContentType (MediaType .APPLICATION_JSON_VALUE );
110118 resp .setHeader ("bar" , "baz" );
111119 }
0 commit comments