Bug 3: Access to screen resource load causes exception. Adding method to know if a LoadTimeLinesGroup is empty or not. Checking children TimeLines are not empty
https://naval.igalia.com/bugtracker/show_bug.cgi?id=3
This commit is contained in:
parent
affd355166
commit
ed1b2011b9
1 changed files with 16 additions and 0 deletions
|
|
@ -36,7 +36,9 @@ public class LoadTimelinesGroup {
|
|||
LocalDate start = null;
|
||||
LocalDate end = null;
|
||||
for (LoadTimelinesGroup loadTimelinesGroup : timeLines) {
|
||||
Validate.notNull(loadTimelinesGroup.getStart());
|
||||
start = min(start, loadTimelinesGroup.getStart());
|
||||
Validate.notNull(loadTimelinesGroup.getEnd());
|
||||
end = max(end, loadTimelinesGroup.getEnd());
|
||||
}
|
||||
return new Interval(toDate(start), toDate(end));
|
||||
|
|
@ -74,11 +76,21 @@ public class LoadTimelinesGroup {
|
|||
List<? extends LoadTimeLine> children) {
|
||||
Validate.notNull(principal);
|
||||
Validate.notNull(children);
|
||||
allChildrenAreNotEmpty(children);
|
||||
this.principal = principal;
|
||||
this.children = Collections
|
||||
.unmodifiableList(new ArrayList<LoadTimeLine>(children));
|
||||
}
|
||||
|
||||
private static void allChildrenAreNotEmpty(
|
||||
List<? extends LoadTimeLine> lines) {
|
||||
for (LoadTimeLine l : lines) {
|
||||
if (l.isEmpty()) {
|
||||
throw new IllegalArgumentException(l + " is empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public LoadTimeLine getPrincipal() {
|
||||
return principal;
|
||||
}
|
||||
|
|
@ -114,5 +126,9 @@ public class LoadTimelinesGroup {
|
|||
return result;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return principal.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue