public List<Group> getGroups() { List<Group> allGroups = Group.findAll(); List<Group> answer = new ArrayList<Group>(); for (Group g : allGroups) { for (User u : g.members) { if (u.equals(this)) { answer.add(g); break; } } } return answer; }
public boolean visible(User user) { if (visibility == Visibility.PRIVATE) return user.equals(owner); if (visibility == Visibility.FRIENDS) return user.equals(owner) || user.isFriendsWith(owner); return true; }