Skip to content

Instantly share code, notes, and snippets.

@andrzejchm
Last active June 29, 2016 12:18
Show Gist options
  • Save andrzejchm/dde97a255ac4e50925e769cd41836ad3 to your computer and use it in GitHub Desktop.
Save andrzejchm/dde97a255ac4e50925e769cd41836ad3 to your computer and use it in GitHub Desktop.
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