Skip to content

Instantly share code, notes, and snippets.

@kaansonmezoz
Created March 25, 2020 19:16
Show Gist options
  • Save kaansonmezoz/30c48e6de8b647766a0fbd08f06a1168 to your computer and use it in GitHub Desktop.
Save kaansonmezoz/30c48e6de8b647766a0fbd08f06a1168 to your computer and use it in GitHub Desktop.
Refactoring Örnek - 1
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