package org.example.shelf.controller;

import java.util.List;

import org.example.shelf.documentation.DocumentationConstants;
import org.example.shelf.exception.ItemNotFoundException;
import org.example.shelf.model.User;
import org.example.shelf.repository.UserRepository;
import org.hildan.livedoc.core.annotations.Api;
import org.hildan.livedoc.core.annotations.ApiError;
import org.hildan.livedoc.core.annotations.ApiErrors;
import org.hildan.livedoc.core.annotations.ApiMethod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/users", produces = MediaType.APPLICATION_JSON_VALUE)
@Api(description = "The user services", name = "User services")
public class UserController {

    @Autowired
    private UserRepository userRepository;

    @ApiMethod(id = DocumentationConstants.USER_FIND_ONE)
    @ApiErrors(apierrors = {
            @ApiError(code = "404", description = "When the user with the given id is not found")
    })
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public User findOne(@PathVariable("id") Long id) throws ItemNotFoundException {
        User findOne = userRepository.findOne(id);
        if (findOne == null) {
            throw new ItemNotFoundException();
        } else {
            return findOne;
        }
    }

    @RequestMapping
    public List<User> findAll() {
        return userRepository.findAll();
    }

}

@@ -1029,32 +1029,142 @@
     
-@Autowired%0A    private U
+private final UserRepository userRepository;%0A%0A    @Autowired%0A    public UserController(UserRepository userRepository) %7B%0A        this.u
 serR
@@ -1164,32 +1164,34 @@
 s.userRepository
+ =
  userRepository;
@@ -1182,32 +1182,38 @@
  userRepository;
+%0A    %7D
 %0A%0A    @ApiMethod

Clean UserController's injection