/** * {@inheritDoc} */ public final int compareTo(final Object arg0) { return compareTo((Dur) arg0); }
/** * {@inheritDoc} */ public boolean equals(final Object obj) { if (obj instanceof Dur) { return ((Dur) obj).compareTo(this) == 0; } return super.equals(obj); }
/** * {@inheritDoc} */ public boolean equals(final Object obj) { if (obj instanceof Dur) { return ((Dur) obj).compareTo(this) == 0; } return super.equals(obj); }
/** * {@inheritDoc} */ public boolean equals(final Object obj) { if (obj instanceof Dur) { return ((Dur) obj).compareTo(this) == 0; } return super.equals(obj); }
/** * {@inheritDoc} */ public boolean equals(final Object obj) { if (obj instanceof Dur) { return ((Dur) obj).compareTo(this) == 0; } return super.equals(obj); }
/** * {@inheritDoc} */ public boolean equals(final Object obj) { if (obj instanceof Dur) { return ((Dur) obj).compareTo(this) == 0; } return super.equals(obj); }
/** * */ public void testCompareToGreater() { assertTrue(duration.compareTo(duration2) > 0); }
/** * Compares the specified period with this period. * First, compare the start dates. If they are the same, compare the end dates. * * @param arg0 a period to compare with this one * @return a postive value if this period is greater, negative if the other is * greater, or zero if they are equal */ public final int compareTo(final Period arg0) { // Throws documented exception if type is wrong or parameter is null if (arg0 == null) { throw new ClassCastException("Cannot compare this object to null"); } final int startCompare = getStart().compareTo(arg0.getStart()); if (startCompare != 0) { return startCompare; } // start dates are equal, compare end dates.. else if (duration == null) { final int endCompare = getEnd().compareTo(arg0.getEnd()); if (endCompare != 0) { return endCompare; } } // ..or durations return getDuration().compareTo(arg0.getDuration()); }
/** * Compares the specified period with this period. * * @param arg0 a period to compare with this one * @return a postive value if this period is greater, negative if the other is * greater, or zero if they are equal */ public final int compareTo(final Period arg0) { // Throws documented exception if type is wrong or parameter is null if (arg0 == null) { throw new ClassCastException("Cannot compare this object to null"); } final int startCompare = getStart().compareTo(arg0.getStart()); if (startCompare != 0) { return startCompare; } // start dates are equal, compare end dates.. else if (duration == null) { final int endCompare = getEnd().compareTo(arg0.getEnd()); if (endCompare != 0) { return endCompare; } } // ..or durations return getDuration().compareTo(arg0.getDuration()); }
/** * Compares the specified period with this period. * First, compare the start dates. If they are the same, compare the end dates. * * @param arg0 a period to compare with this one * @return a postive value if this period is greater, negative if the other is * greater, or zero if they are equal */ public final int compareTo(final Period arg0) { // Throws documented exception if type is wrong or parameter is null if (arg0 == null) { throw new ClassCastException("Cannot compare this object to null"); } final int startCompare = getStart().compareTo(arg0.getStart()); if (startCompare != 0) { return startCompare; } // start dates are equal, compare end dates.. else if (duration == null) { final int endCompare = getEnd().compareTo(arg0.getEnd()); if (endCompare != 0) { return endCompare; } } // ..or durations return getDuration().compareTo(arg0.getDuration()); }
if (freeDuration.getDuration().compareTo(duration) >= 0) { fb.getPeriods().add(new Period(lastPeriodEnd, freeDuration.getDuration()));
public FreeBusy build() { final FreeBusy fb = new FreeBusy(); fb.getParameters().add(FbType.FREE); final PeriodList periods = getConsumedTime(components, start, end); final DateRange range = new DateRange(start, end); // Add final consumed time to avoid special-case end-of-list processing periods.add(new Period(end, end)); DateTime lastPeriodEnd = new DateTime(start); // where no time is consumed set the last period end as the range start.. for (final Period period : periods) { // check if period outside bounds.. or period intersects with the end of the range.. if (range.contains(period) || (range.intersects(period) && period.getStart().after(range.getRangeStart()))) { // calculate duration between this period start and last period end.. final Duration freeDuration = new Duration(lastPeriodEnd, period.getStart()); if (freeDuration.getDuration().compareTo(duration) >= 0) { fb.getPeriods().add(new Period(lastPeriodEnd, freeDuration.getDuration())); } } if (period.getEnd().after(lastPeriodEnd)) { lastPeriodEnd = period.getEnd(); } } return fb; } }
public FreeBusy build() { final FreeBusy fb = new FreeBusy(); fb.getParameters().add(FbType.FREE); final PeriodList periods = getConsumedTime(components, start, end); final DateRange range = new DateRange(start, end); // Add final consumed time to avoid special-case end-of-list processing periods.add(new Period(end, end)); DateTime lastPeriodEnd = new DateTime(start); // where no time is consumed set the last period end as the range start.. for (final Period period : periods) { // check if period outside bounds.. or period intersects with the end of the range.. if (range.contains(period) || (range.intersects(period) && period.getStart().after(range.getRangeStart()))) { // calculate duration between this period start and last period end.. final Duration freeDuration = new Duration(lastPeriodEnd, period.getStart()); if (freeDuration.getDuration().compareTo(duration) >= 0) { fb.getPeriods().add(new Period(lastPeriodEnd, freeDuration.getDuration())); } } if (period.getEnd().after(lastPeriodEnd)) { lastPeriodEnd = period.getEnd(); } } return fb; } }