我使用可选工具进行用户和邀请验证
@DeleteMapping("/friends/{username}")
public
HttpEntity<Boolean> removeFriend(
@ApiParam(value = "The user's name", required = true) @PathVariable String username
) {
Long fromId = authorizationService.getUserId();
return userService.findByUsername(username)
.map(user -> {
return friendshipService.findFriendship(fromId, user.getId())
.map(friendship -> {
friendshipService.removeFriendship(friendship);
friendship.setToId(friendship.getFromId());
friendship.setFromId(friendship.getToId());
friendshipService.removeFriendship(friendship);
return ResponseEntity.ok(true);
}).orElseGet(() -> ResponseEntity.notFound().build());
}).orElseThrow(() -> new ResourceNotFoundException("User not found"));
However, IntelliJ
is colouring my grey return
, But when I remove the return
, it highlights to me that there is no return
.
有人可以解释它是如何工作的以及它是关于什么的吗?
原文由 sdfsd 发布,翻译遵循 CC BY-SA 4.0 许可协议
你的 陈述拉姆达
可以更改为 表达式 lambda :
很简单,不是吗?请注意,需要删除大括号和分号。