ItEr33S08ValidacionEProbasFuncionaisItEr32S09: Copying mutable values in order to preserve encapsulation
This commit is contained in:
parent
194735979e
commit
984b98f317
10 changed files with 32 additions and 23 deletions
|
|
@ -30,13 +30,13 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
|
|||
|
||||
private String name;
|
||||
|
||||
private Date beginDate = null;
|
||||
private long beginDate;
|
||||
|
||||
private long lengthMilliseconds = 0;
|
||||
|
||||
private String notes;
|
||||
|
||||
private Date hoursAdvanceEndDate;
|
||||
private long hoursAdvanceEndDate;
|
||||
|
||||
private Date advanceEndDate;
|
||||
|
||||
|
|
@ -55,10 +55,10 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
|
|||
Date advanceEndDate,
|
||||
BigDecimal hoursAdvancePercentage, BigDecimal advancePercentage) {
|
||||
this.name = name;
|
||||
this.beginDate = beginDate;
|
||||
this.beginDate = beginDate.getTime();
|
||||
this.lengthMilliseconds = lengthMilliseconds;
|
||||
this.notes = notes;
|
||||
this.hoursAdvanceEndDate = hoursAdvanceEndDate;
|
||||
this.hoursAdvanceEndDate = hoursAdvanceEndDate.getTime();
|
||||
this.advanceEndDate = advanceEndDate;
|
||||
this.hoursAdvancePercentage = hoursAdvancePercentage;
|
||||
this.advancePercentage = advancePercentage;
|
||||
|
|
@ -74,11 +74,11 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
|
|||
}
|
||||
|
||||
public Date getBeginDate() {
|
||||
return beginDate;
|
||||
return new Date(beginDate);
|
||||
}
|
||||
|
||||
public long setBeginDate(Date beginDate) {
|
||||
this.beginDate = beginDate;
|
||||
this.beginDate = beginDate.getTime();
|
||||
return lengthMilliseconds;
|
||||
}
|
||||
|
||||
|
|
@ -105,12 +105,13 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
|
|||
|
||||
@Override
|
||||
public Date getHoursAdvanceEndDate() {
|
||||
return hoursAdvanceEndDate;
|
||||
return new Date(hoursAdvanceEndDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getAdvanceEndDate() {
|
||||
return advanceEndDate;
|
||||
return advanceEndDate != null ? new Date(advanceEndDate.getTime())
|
||||
: null;
|
||||
}
|
||||
@Override
|
||||
public BigDecimal getHoursAdvancePercentage() {
|
||||
|
|
|
|||
|
|
@ -166,6 +166,9 @@ public abstract class Task implements ITaskFundamentalProperties {
|
|||
}
|
||||
|
||||
public void setEndDate(Date value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
setLengthMilliseconds(value.getTime() - getBeginDate().getTime());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class ValidationException extends RuntimeException {
|
|||
private InvalidValue[] invalidValues;
|
||||
|
||||
public InvalidValue[] getInvalidValues() {
|
||||
return invalidValues;
|
||||
return invalidValues.clone();
|
||||
}
|
||||
|
||||
public ValidationException(InvalidValue invalidValue) {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class IntervalOfPartialDatesType implements CompositeUserType {
|
|||
|
||||
@Override
|
||||
public String[] getPropertyNames() {
|
||||
return PROPERTY_NAMES;
|
||||
return PROPERTY_NAMES.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -137,11 +137,12 @@ public abstract class TaskElement extends BaseEntity {
|
|||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
return startDate != null ? new Date(startDate.getTime()) : null;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
this.startDate = startDate != null ? new Date(startDate.getTime())
|
||||
: null;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -150,6 +151,9 @@ public abstract class TaskElement extends BaseEntity {
|
|||
* @param newStartDate
|
||||
*/
|
||||
public void moveTo(Date newStartDate) {
|
||||
if (newStartDate == null) {
|
||||
return;
|
||||
}
|
||||
long durationMilliseconds = this.endDate.getTime()
|
||||
- this.startDate.getTime();
|
||||
this.startDate = newStartDate;
|
||||
|
|
@ -160,11 +164,11 @@ public abstract class TaskElement extends BaseEntity {
|
|||
protected abstract void moveAllocations();
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
return endDate != null ? new Date(endDate.getTime()) : endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
this.endDate = endDate != null ? new Date(endDate.getTime()) : null;
|
||||
}
|
||||
|
||||
void add(Dependency dependency) {
|
||||
|
|
|
|||
|
|
@ -79,11 +79,11 @@ public class WorkReport extends BaseEntity {
|
|||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
return date != null ? new Date(date.getTime()) : null;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
this.date = date != null ? new Date(date.getTime()) : null;
|
||||
}
|
||||
|
||||
public String getPlace() {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,8 @@ public class BaseCalendarModel implements IBaseCalendarModel {
|
|||
|
||||
@Override
|
||||
public Date getSelectedDay() {
|
||||
return this.selectedDate;
|
||||
return selectedDate != null ? new Date(this.selectedDate.getTime())
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -51,15 +51,15 @@ public class CalendarHighlightedDays extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
public Date getInternalValue() {
|
||||
return value;
|
||||
return value != null ? new Date(value.getTime()) : null;
|
||||
}
|
||||
|
||||
public void setValue(Date value) {
|
||||
this.value = value;
|
||||
this.value = value != null ? new Date(value.getTime()) : null;
|
||||
}
|
||||
|
||||
public Date getValue() {
|
||||
return value;
|
||||
return value != null ? new Date(value.getTime()) : null;
|
||||
}
|
||||
|
||||
public void setAncestorExceptionDays(String ancestorExceptionDays) {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class LabelBandboxFinder extends BandboxFinder implements IBandboxFinder
|
|||
|
||||
@Override
|
||||
public String[] getHeaders() {
|
||||
return headers;
|
||||
return headers.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -99,11 +99,11 @@ public class CriterionSatisfactionDTO implements INewObject {
|
|||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
return new Date(startDate.getTime());
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
return new Date(endDate.getTime());
|
||||
}
|
||||
|
||||
public CriterionSatisfaction getCriterionSatisfaction() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue