Last active
June 29, 2016 12:18
-
-
Save andrzejchm/dde97a255ac4e50925e769cd41836ad3 to your computer and use it in GitHub Desktop.
This file contains 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 class GoodPresentationModel implements Serializable { | |
public static final Birthday TODAY = new Birthday(); | |
private List<User> users = Collections.emptyList(); | |
public void setUsers(List<User> users) { | |
this.users = users; | |
} | |
public boolean shouldDisplayEmptyState() { | |
return users.isEmpty(); | |
} | |
public List<User> getAllUsers() { | |
return Collections.unmodifiableList(users); | |
} | |
public List<User> hasAnyUserBirthdayToday() { | |
for (User user : users) { | |
if (isBirthdayToday(user.getBirthday())) { | |
return true; | |
} | |
} | |
return false; | |
} | |
public List<User> getUsersWithBirthday() { | |
List<Users> result = new LinkedList<>(); | |
for (User user : users) { | |
if (isBirthdayToday(user.getBirthday())) { | |
result.add(user); | |
} | |
} | |
return Collections.unmodifiableList(result); | |
} | |
private boolean isBirthdayToday(Birthday birthday) { | |
return birthday.getMonth() == TODAY.getMonth() && birthday.getDay() == TODAY.getDay(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment