Skip to content

Instantly share code, notes, and snippets.

@kaansonmezoz
Last active March 25, 2020 20:52
Show Gist options
  • Save kaansonmezoz/c9360425d6a6e28e341f6ea519a63e03 to your computer and use it in GitHub Desktop.
Save kaansonmezoz/c9360425d6a6e28e341f6ea519a63e03 to your computer and use it in GitHub Desktop.
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 = false;
for (User friend : user.getFriends()) {
if (friend.equals(loggedUser)) {
isFriend = true;
break;
}
}
if (isFriend) {
tripList = TripDAO.findTripsByUser(user);
}
return tripList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment