Created
March 25, 2020 21:36
-
-
Save kaansonmezoz/cb3bc703e6303a792be9ad1cb5c490d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public List<Trip> getTripsByUser(User user) throws UserNotLoggedInException { | |
| User loggedUser = UserSession.getInstance().getLoggedUser(); | |
| if(loggedUser == null){ | |
| throw new UserNotLoggedInException(); | |
| } | |
| List<Trip> tripList = new ArrayList<Trip>(); | |
| boolean isFriend = isFriendOf(user, loggedUser); | |
| if (isFriend) { | |
| tripList = TripDAO.findTripsByUser(user); | |
| } | |
| return tripList; | |
| } | |
| private boolean isFriendOf(User user, User loggedUser){ | |
| return user.getFriends().contains(loggedUser); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment