Skip to content
Snippets Groups Projects
Commit e76e0719 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Filtering out potential null objects in list

parent 960f59f3
Branches
Tags
No related merge requests found
......@@ -56,7 +56,7 @@ public class DateTimeInterval {
*/
public static Date getLastEndDate(List<DateTimeInterval> intervals)
{
OptionalLong max = intervals.stream().mapToLong(i->i.getEnd().getTime()).max();
OptionalLong max = intervals.stream().filter(i -> i != null).mapToLong(i -> i.getEnd().getTime()).max();
return max.isPresent() ? new Date(max.getAsLong()) : null;
}
......@@ -67,7 +67,7 @@ public class DateTimeInterval {
*/
public static Date getFirstStartDate(List<DateTimeInterval> intervals)
{
OptionalLong min = intervals.stream().mapToLong(i->i.getStart().getTime()).min();
OptionalLong min = intervals.stream().filter(i -> i != null).mapToLong(i->i.getStart().getTime()).min();
return min.isPresent() ? new Date(min.getAsLong()) : null;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment