ADD:: added javadoc comments where needed for the checkstyle

EDIT:: edited some lines to fit the checkstyle

fixed some indentation warnings and line length warnings
This commit is contained in:
Sem van der Hoeven
2019-03-11 16:44:55 +01:00
parent ece58798f1
commit 5877e307d5
9 changed files with 136 additions and 83 deletions

View File

@@ -20,20 +20,38 @@ public class User {
String name;
String password;
/**
* makes a user object.
* @param id the id of the user.
* @param name the supplied username
* @param password the supplied password
*/
public User(Long id, String name, String password) {
this.id = id;
this.name = name;
this.password = password;
}
/**
* gets the id.
* @return the id
*/
public Long getId() {
return id;
}
/**
* gets the name.
* @return the name
*/
public String getName() {
return name;
}
/**
* gets the password.
* @return the password
*/
public String getPassword() {
return password;
}

View File

@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
public class RestExceptionHandler {
@ExceptionHandler(ApplicationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ErrorResponse applicationException (ApplicationException ex) {
public ErrorResponse applicationException(ApplicationException ex) {
return new ErrorResponse(ex.getMessage());
}
}

View File

@@ -13,14 +13,14 @@ public class UserController {
UserService userService;
@RequestMapping("/registerUser")
public UserDTO registerUser(@RequestParam(value="name") String name,
@RequestParam(value="password") String password) {
public UserDTO registerUser(@RequestParam(value = "name") String name,
@RequestParam(value = "password") String password) {
return userService.registerUser(name, password);
}
@RequestMapping("/login")
public UserDTO login(@RequestParam(value="name") String name,
@RequestParam(value="password") String password) {
public UserDTO login(@RequestParam(value = "name") String name,
@RequestParam(value = "password") String password) {
return userService.login(name, password);
}
}

View File

@@ -15,6 +15,12 @@ public class UserService {
@Autowired
UserRepository userRepository;
/**
* registers the user.
* @param name the username of the user
* @param password the password of the user
* @return a userDTO of the registered user
*/
public UserDTO registerUser(String name, String password) {
User user = userRepository.findByName(name);
if (user != null) {
@@ -26,6 +32,12 @@ public class UserService {
return new UserDTO(user.getId(), user.getName());
}
/**
* logs the user in.
* @param name the username of the user
* @param password the password of the user
* @return a userDTO of the logged in user
*/
public UserDTO login(String name, String password) {
User user = userRepository.findByName(name);
if (user == null) {