From f30e2f0c5a8223ef333b9228c03a116ef853937d Mon Sep 17 00:00:00 2001 From: Nacho Barrientos Date: Mon, 14 Nov 2011 17:42:56 +0100 Subject: [PATCH] Avoid using equals to compare if task progress is zero or one, use compareTo instead. BigDecimal.ZERO and BigDecimal("0.0000") are not conceptually the same thus equals returns false. FEA: ItEr75S27PerProjectDashboard --- .../org/libreplan/business/planner/entities/Task.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/Task.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/Task.java index ff7e6ab32..67314664c 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/Task.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/Task.java @@ -1134,7 +1134,7 @@ public class Task extends TaskElement implements ITaskPositionConstrained { if (this.currentStatus != null) { return this.currentStatus == TaskStatusEnum.FINISHED; } else { - boolean outcome = this.getAdvancePercentage().equals(BigDecimal.ONE); + boolean outcome = this.advancePercentageIsOne(); if (outcome == true) { this.currentStatus = TaskStatusEnum.FINISHED; } @@ -1147,9 +1147,8 @@ public class Task extends TaskElement implements ITaskPositionConstrained { if (this.currentStatus != null) { return this.currentStatus == TaskStatusEnum.IN_PROGRESS; } else { - BigDecimal currentAdvancePercentage = this.getAdvancePercentage(); boolean advanceBetweenZeroAndOne = this.advancePertentageIsGreaterThanZero() && - !currentAdvancePercentage.equals(BigDecimal.ONE); + !advancePercentageIsOne(); boolean outcome = advanceBetweenZeroAndOne || this.hasAttachedWorkReports(); if (outcome == true) { this.currentStatus = TaskStatusEnum.IN_PROGRESS; @@ -1205,7 +1204,11 @@ public class Task extends TaskElement implements ITaskPositionConstrained { } private boolean advancePercentageIsZero() { - return this.getAdvancePercentage().equals(BigDecimal.ZERO); + return this.getAdvancePercentage().compareTo(BigDecimal.ZERO) == 0; + } + + private boolean advancePercentageIsOne() { + return this.getAdvancePercentage().compareTo(BigDecimal.ONE) == 0; } private boolean hasAttachedWorkReports() {