Add function getNextDeadline()

This commit is contained in:
T-Midnight 2018-12-23 02:22:06 +04:00
parent eff5344aea
commit edd38beb67

View File

@ -10,11 +10,7 @@ import ru.ulstu.user.model.User;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
@Entity
public class Grant extends BaseEntity {
@ -103,4 +99,13 @@ public class Grant extends BaseEntity {
public void setProject(Project project) {
this.project = project;
}
public Optional<Deadline> getNextDeadline() {
return deadlines
.stream()
.filter(deadline -> deadline.getDate() != null)
.sorted(Comparator.comparing(Deadline::getDate))
.filter(d -> d.getDate().after(new Date()))
.findFirst();
}
}