Skip to content

Commit

Permalink
-Call the static method Integer.compare(...) instead of instantiating…
Browse files Browse the repository at this point in the history
… a temporary object.

-Replace this if-then-else statement by a single return statement
  • Loading branch information
RodrigoZambrana committed Jan 2, 2025
1 parent 6e5d702 commit 192f738
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,10 @@ public int compare(Candidate candidate1, Candidate candidate2) {
else if (candidate2.getCandidateOrder() == Constants.MAX_ORDER)
result = Constants.MAX_ORDER;
else if (election.isRandomOrderCandidates()) {
result = Integer.valueOf(rand.nextInt(30)).compareTo(Integer.valueOf(rand.nextInt(30)));
} else
result = (Integer.valueOf(candidate2.getCandidateOrder()).compareTo(Integer.valueOf(candidate1.getCandidateOrder())));
result = Integer.compare(rand.nextInt(30), rand.nextInt(30));
} else {
result = Integer.compare(candidate2.getCandidateOrder(), candidate1.getCandidateOrder());
}
return result;
}
});
Expand Down Expand Up @@ -1864,11 +1865,7 @@ public boolean electionCanBeClosed(long electionId) {
Date endDate = election.getEndDate();
Date currentDate = DateTime.now().toDate();

if ((!closed) && (endDate.before(currentDate))) {
return true;
} else {
return false;
}
return !closed && endDate.before(currentDate);
} catch (Exception e) {
appLogger.error(e);
return false;
Expand Down

0 comments on commit 192f738

Please sign in to comment.