throw new UserNotLoggedInException();\r
}\r
\r
- // Getting rid of variables in legacy code is great because if we do it,\r
- // it will be easier for us to refactor the code.\r
- // Once we take away as many variables as posible we can remake optimizations\r
- // but not before.\r
- // We managed to get a symmetrical if (ternary operation)\r
- if (user.isFriendsWith(loggedInUser)) {\r
- return tripsBy(user);\r
- } else {\r
- return new ArrayList<>();\r
- }\r
+ return user.isFriendsWith(loggedInUser)\r
+ ? tripsBy(user)\r
+ : new ArrayList<>();\r
}\r
\r
protected List<Trip> tripsBy(User user) {\r