ItEr32S12CUAsignacionGrupoRecursosAPlanificacionItEr31S15: Adding method to coalesce intervals
This commit is contained in:
parent
d6e99ca766
commit
517d8a280d
1 changed files with 11 additions and 0 deletions
|
|
@ -23,8 +23,12 @@
|
|||
*/
|
||||
package org.zkoss.ganttz.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
public class Interval {
|
||||
private final Date start;
|
||||
|
||||
|
|
@ -79,4 +83,11 @@ public class Interval {
|
|||
private boolean isIncluded(Date date) {
|
||||
return start.compareTo(date) <= 0 && finish.compareTo(date) >= 0;
|
||||
}
|
||||
|
||||
public Interval coalesce(Interval otherInterval) {
|
||||
Validate.notNull(otherInterval);
|
||||
return new Interval(Collections.min(Arrays.asList(start,
|
||||
otherInterval.start)), Collections.max(Arrays.asList(finish,
|
||||
otherInterval.finish)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue