Add function getNextDeadline()
This commit is contained in:
parent
eff5344aea
commit
edd38beb67
@ -10,11 +10,7 @@ import ru.ulstu.user.model.User;
|
|||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Grant extends BaseEntity {
|
public class Grant extends BaseEntity {
|
||||||
@ -103,4 +99,13 @@ public class Grant extends BaseEntity {
|
|||||||
public void setProject(Project project) {
|
public void setProject(Project project) {
|
||||||
this.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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user