Fix violation of the intended immutability of IntraDayDate

A comment in the javadoc is added stating it. Final keyword is added
to the class so the immutability is not bypassed using
subclasses. Final cannot be applied to the fields because it must have
an empty constructor for Hibernate.

FEA: ItEr74S04BugFixing
This commit is contained in:
Óscar González Fernández 2011-05-11 18:44:00 +02:00
parent 77bf52ee44
commit f569d6d2c7
2 changed files with 5 additions and 6 deletions

View file

@ -41,6 +41,10 @@ import org.joda.time.Days;
import org.joda.time.LocalDate;
/**
* <p>
* Instances of this class represent values so immutable objects are used. In
* order to do modifications new instances must be created.
* </p>
* <p>
* A date type that represents a point inside a working day. This doesn't
* translate directly to a concrete DateTime because the working day can start
@ -187,10 +191,6 @@ public class IntraDayDate implements Comparable<IntraDayDate> {
return getDate().plusDays(1);
}
public void plus(int days) {
this.date = this.date.plusDays(days);
}
public int compareTo(LocalDate other) {
int result = this.date.compareTo(other);
if (result != 0) {

View file

@ -253,8 +253,7 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel {
Arrays.asList(resourceAllocation
.asResourcesPerDayModification()))
.untilAllocating(hours(pendingHours));
date.plus(1);
task.setIntraDayEndDate(date);
task.setIntraDayEndDate(date.nextDayAtStart());
}
} else {
reassign(resourceAllocation, startInclusive, endExclusive,