Created
March 25, 2020 19:16
-
-
Save kaansonmezoz/30c48e6de8b647766a0fbd08f06a1168 to your computer and use it in GitHub Desktop.
Refactoring Örnek - 1
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 { | |
| List<Trip> tripList = new ArrayList<Trip>(); | |
| User loggedUser = UserSession.getInstance().getLoggedUser(); | |
| boolean isFriend = false; | |
| if (loggedUser != null) { | |
| for (User friend : user.getFriends()) { | |
| if (friend.equals(loggedUser)) { | |
| isFriend = true; | |
| break; | |
| } | |
| } | |
| if (isFriend) { | |
| tripList = TripDAO.findTripsByUser(user); | |
| } | |
| return tripList; | |
| } else { | |
| throw new UserNotLoggedInException(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment