}\r
\r
public List<Trip> getTripsByUser(User user, User loggedInUser) throws UserNotLoggedInException {\r
- if (loggedInUser == null) {\r
- throw new UserNotLoggedInException();\r
- }\r
+ validate(loggedInUser);\r
\r
return user.isFriendsWith(loggedInUser)\r
? tripsBy(user)\r
: noTrips();\r
}\r
\r
+ private void validate(User loggedInUser) {\r
+ if (loggedInUser == null) {\r
+ throw new UserNotLoggedInException();\r
+ }\r
+ }\r
+\r
private ArrayList<Trip> noTrips() {\r
return new ArrayList<>();\r
}\r