FINERACT-822 Enforce UndefinedEquals check (#1099)

This commit is contained in:
Percy Ayuk Ashu
2020-06-23 22:36:52 +02:00
committed by GitHub
parent d70af43f13
commit f1a06b42d7
14 changed files with 66 additions and 41 deletions
+1 -1
View File
@@ -385,7 +385,6 @@ tasks.withType(JavaCompile) {
"UnusedVariable",
"SameNameButDifferent",
"TypeParameterUnusedInFormals",
"UndefinedEquals",
"JdkObsolete",
"EmptyBlockTag",
"MissingSummary",
@@ -453,6 +452,7 @@ tasks.withType(JavaCompile) {
"NarrowingCompoundAssignment",
"MissingCasesInEnumSwitch",
"ReferenceEquality",
"UndefinedEquals",
"OperatorPrecedence",
"EqualsGetClass",
"EqualsUnsafeCast",
@@ -100,8 +100,9 @@ public class TrialBalance extends AbstractPersistableCustom {
}
TrialBalance other = (TrialBalance) obj;
return Objects.equals(other.officeId, officeId) && Objects.equals(other.glAccountId, glAccountId)
&& Objects.equals(other.amount, amount) && Objects.equals(other.entryDate, entryDate)
&& Objects.equals(other.transactionDate, transactionDate) && Objects.equals(other.closingBalance, closingBalance);
&& Objects.equals(other.amount, amount) && other.entryDate.compareTo(entryDate) == 0 ? Boolean.TRUE
: Boolean.FALSE && other.transactionDate.compareTo(transactionDate) == 0 ? Boolean.TRUE
: Boolean.FALSE && Objects.equals(other.closingBalance, closingBalance);
}
@Override
@@ -530,7 +530,9 @@ public class AccountingProcessorHelper {
* check if an accounting closure has happened for this branch after the transaction Date
**/
if (latestGLClosure != null) {
if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().equals(transactionDate)) {
if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().compareTo(transactionDate) == 0
? Boolean.TRUE
: Boolean.FALSE) {
throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(),
null, null);
}
@@ -346,7 +346,8 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final GLClosure latestGLClosureByBranch = this.glClosureRepository.getLatestGLClosureByBranch(officeId);
if (latestGLClosureByBranch != null) {
if (latestGLClosureByBranch.getClosingDate().after(journalEntriesTransactionDate)
|| latestGLClosureByBranch.getClosingDate().equals(journalEntriesTransactionDate)) {
|| latestGLClosureByBranch.getClosingDate().compareTo(journalEntriesTransactionDate) == 0 ? Boolean.TRUE
: Boolean.FALSE) {
final String accountName = null;
final String accountGLCode = null;
throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED,
@@ -597,7 +598,9 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
// shouldn't be before an accounting closure
final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(command.getOfficeId());
if (latestGLClosure != null) {
if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().equals(transactionDate)) {
if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().compareTo(transactionDate) == 0
? Boolean.TRUE
: Boolean.FALSE) {
throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(),
null, null);
}
@@ -133,7 +133,7 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
private void validateForCreateJournalEntry(ProvisioningEntryData existingEntry, ProvisioningEntry requested) {
Date existingDate = existingEntry.getCreatedDate();
Date requestedDate = requested.getCreatedDate();
if (existingDate.after(requestedDate) || existingDate.equals(requestedDate)) {
if (existingDate.after(requestedDate) || existingDate.compareTo(requestedDate) == 0 ? Boolean.TRUE : Boolean.FALSE) {
throw new ProvisioningJournalEntriesCannotbeCreatedException(existingEntry.getCreatedDate(), requestedDate);
}
}
@@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.fineract.portfolio.loanproduct.data.LoanProductData;
import org.apache.fineract.portfolio.savings.data.SavingsProductData;
@@ -69,7 +70,8 @@ public class EntityDataTableChecksTemplateData implements Serializable {
return Objects.equals(entities, that.entities) && Objects.equals(statusClient, that.statusClient)
&& Objects.equals(statusGroup, that.statusGroup) && Objects.equals(statusSavings, that.statusSavings)
&& Objects.equals(statusLoans, that.statusLoans) && Objects.equals(datatables, that.datatables)
&& Objects.equals(loanProductDatas, that.loanProductDatas) && Objects.equals(savingsProductDatas, that.savingsProductDatas);
&& CollectionUtils.isEqualCollection(loanProductDatas, that.loanProductDatas)
&& CollectionUtils.isEqualCollection(savingsProductDatas, that.savingsProductDatas);
}
@Override
@@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.portfolio.calendar.domain.CalendarFrequencyType;
import org.apache.fineract.portfolio.calendar.domain.CalendarRemindBy;
@@ -525,8 +526,10 @@ public final class CalendarData implements Serializable {
&& Objects.equals(frequency, that.frequency) && Objects.equals(interval, that.interval)
&& Objects.equals(repeatsOnDay, that.repeatsOnDay) && Objects.equals(repeatsOnNthDayOfMonth, that.repeatsOnNthDayOfMonth)
&& Objects.equals(remindBy, that.remindBy) && Objects.equals(firstReminder, that.firstReminder)
&& Objects.equals(secondReminder, that.secondReminder) && Objects.equals(recurringDates, that.recurringDates)
&& Objects.equals(nextTenRecurringDates, that.nextTenRecurringDates) && Objects.equals(humanReadable, that.humanReadable)
&& Objects.equals(secondReminder, that.secondReminder)
&& CollectionUtils.isEqualCollection(recurringDates, that.recurringDates)
&& CollectionUtils.isEqualCollection(nextTenRecurringDates, that.nextTenRecurringDates)
&& Objects.equals(humanReadable, that.humanReadable)
&& Objects.equals(recentEligibleMeetingDate, that.recentEligibleMeetingDate)
&& Objects.equals(createdDate, that.createdDate) && Objects.equals(lastUpdatedDate, that.lastUpdatedDate)
&& Objects.equals(createdByUserId, that.createdByUserId) && Objects.equals(createdByUsername, that.createdByUsername)
@@ -23,6 +23,7 @@ import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.dataqueries.data.DatatableData;
@@ -280,11 +281,12 @@ public final class CenterData implements Serializable {
&& Objects.equals(officeName, that.officeName) && Objects.equals(staffId, that.staffId)
&& Objects.equals(staffName, that.staffName) && Objects.equals(hierarchy, that.hierarchy)
&& Objects.equals(status, that.status) && Objects.equals(activationDate, that.activationDate)
&& Objects.equals(timeline, that.timeline) && Objects.equals(groupMembers, that.groupMembers)
&& Objects.equals(groupMembersOptions, that.groupMembersOptions)
&& Objects.equals(timeline, that.timeline) && CollectionUtils.isEqualCollection(groupMembers, that.groupMembers)
&& CollectionUtils.isEqualCollection(groupMembersOptions, that.groupMembersOptions)
&& Objects.equals(collectionMeetingCalendar, that.collectionMeetingCalendar)
&& Objects.equals(closureReasons, that.closureReasons) && Objects.equals(officeOptions, that.officeOptions)
&& Objects.equals(staffOptions, that.staffOptions) && Objects.equals(totalCollected, that.totalCollected)
&& CollectionUtils.isEqualCollection(closureReasons, that.closureReasons)
&& CollectionUtils.isEqualCollection(officeOptions, that.officeOptions)
&& CollectionUtils.isEqualCollection(staffOptions, that.staffOptions) && Objects.equals(totalCollected, that.totalCollected)
&& Objects.equals(totalOverdue, that.totalOverdue) && Objects.equals(totaldue, that.totaldue)
&& Objects.equals(installmentDue, that.installmentDue) && Objects.equals(datatables, that.datatables)
&& Objects.equals(rowIndex, that.rowIndex) && Objects.equals(dateFormat, that.dateFormat)
@@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.dataqueries.data.DatatableData;
@@ -380,14 +381,17 @@ public class GroupGeneralData implements Serializable {
&& Objects.equals(officeName, that.officeName) && Objects.equals(centerId, that.centerId)
&& Objects.equals(centerName, that.centerName) && Objects.equals(staffId, that.staffId)
&& Objects.equals(staffName, that.staffName) && Objects.equals(hierarchy, that.hierarchy)
&& Objects.equals(groupLevel, that.groupLevel) && Objects.equals(clientMembers, that.clientMembers)
&& Objects.equals(activeClientMembers, that.activeClientMembers) && Objects.equals(groupRoles, that.groupRoles)
&& Objects.equals(calendarsData, that.calendarsData)
&& Objects.equals(groupLevel, that.groupLevel) && CollectionUtils.isEqualCollection(clientMembers, that.clientMembers)
&& CollectionUtils.isEqualCollection(activeClientMembers, that.activeClientMembers)
&& CollectionUtils.isEqualCollection(groupRoles, that.groupRoles)
&& CollectionUtils.isEqualCollection(calendarsData, that.calendarsData)
&& Objects.equals(collectionMeetingCalendar, that.collectionMeetingCalendar)
&& Objects.equals(centerOptions, that.centerOptions) && Objects.equals(officeOptions, that.officeOptions)
&& Objects.equals(staffOptions, that.staffOptions) && Objects.equals(clientOptions, that.clientOptions)
&& Objects.equals(availableRoles, that.availableRoles) && Objects.equals(selectedRole, that.selectedRole)
&& Objects.equals(closureReasons, that.closureReasons) && Objects.equals(timeline, that.timeline)
&& CollectionUtils.isEqualCollection(centerOptions, that.centerOptions)
&& CollectionUtils.isEqualCollection(officeOptions, that.officeOptions)
&& CollectionUtils.isEqualCollection(staffOptions, that.staffOptions)
&& CollectionUtils.isEqualCollection(clientOptions, that.clientOptions)
&& CollectionUtils.isEqualCollection(availableRoles, that.availableRoles) && Objects.equals(selectedRole, that.selectedRole)
&& CollectionUtils.isEqualCollection(closureReasons, that.closureReasons) && Objects.equals(timeline, that.timeline)
&& Objects.equals(datatables, that.datatables) && Objects.equals(rowIndex, that.rowIndex)
&& Objects.equals(dateFormat, that.dateFormat) && Objects.equals(locale, that.locale)
&& Objects.equals(submittedOnDate, that.submittedOnDate);
@@ -2529,7 +2529,7 @@ public class Loan extends AbstractPersistableCustom {
Date date = null;
for (LoanDisbursementDetails disbursementDetail : this.disbursementDetails) {
if (disbursementDetail.actualDisbursementDate() == null) {
if (date == null || disbursementDetail.expectedDisbursementDate().equals(date)) {
if (date == null || disbursementDetail.expectedDisbursementDate().compareTo(date) == 0 ? Boolean.TRUE : Boolean.FALSE) {
disbursementDetails.add(disbursementDetail);
date = disbursementDetail.expectedDisbursementDate();
} else if (disbursementDetail.expectedDisbursementDate().before(date)) {
@@ -2549,7 +2549,7 @@ public class Loan extends AbstractPersistableCustom {
for (LoanDisbursementDetails disbursementDetail : this.disbursementDetails) {
if (disbursementDetail.actualDisbursementDate() != null) {
if (disbursementDetail.actualDisbursementDate().after(date)
|| disbursementDetail.actualDisbursementDate().equals(date)) {
|| disbursementDetail.actualDisbursementDate().compareTo(date) == 0 ? Boolean.TRUE : Boolean.FALSE) {
date = disbursementDetail.actualDisbursementDate();
details = disbursementDetail;
}
@@ -2752,7 +2752,7 @@ public class Loan extends AbstractPersistableCustom {
if (getExpectedFirstRepaymentOnDate() != null
&& (disbursedOn.isAfter(this.fetchRepaymentScheduleInstallment(1).getDueDate())
|| disbursedOn.isAfter(getExpectedFirstRepaymentOnDate()))
&& disbursedOn.toDate().equals(this.actualDisbursementDate)) {
&& disbursedOn.toDate().compareTo(this.actualDisbursementDate) == 0 ? Boolean.TRUE : Boolean.FALSE) {
final String errorMessage = "submittedOnDate cannot be after the loans expectedFirstRepaymentOnDate: "
+ getExpectedFirstRepaymentOnDate().toString();
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.after.expected.first.repayment.date", errorMessage,
@@ -3970,7 +3970,8 @@ public class Loan extends AbstractPersistableCustom {
boolean isRegenerationRequired = false;
if (this.loanProduct.isMultiDisburseLoan()) {
LoanDisbursementDetails details = fetchLastDisburseDetail();
if (details != null && !details.expectedDisbursementDate().equals(details.actualDisbursementDate())) {
if (details != null && details.expectedDisbursementDate().compareTo(details.actualDisbursementDate()) == 0 ? Boolean.FALSE
: Boolean.TRUE) {
isRegenerationRequired = true;
}
}
@@ -6016,7 +6017,8 @@ public class Loan extends AbstractPersistableCustom {
if ((loanTermVariations.getTermType().isDueDateVariation()
&& loanTermVariations.fetchDateValue().isAfter(actualDisbursementDate))
|| (loanTermVariations.getTermType().isEMIAmountVariation()
&& loanTermVariations.getTermApplicableFrom().equals(actualDisbursementDate.toDate()))
&& loanTermVariations.getTermApplicableFrom().compareTo(actualDisbursementDate.toDate()) == 0 ? Boolean.TRUE
: Boolean.FALSE)
|| loanTermVariations.getTermApplicableFrom().after(actualDisbursementDate.toDate())) {
iterator.remove();
}
@@ -72,7 +72,8 @@ public class LoanDisbursementDetails extends AbstractPersistableCustom {
}
final LoanDisbursementDetails loanDisbursementDetails = (LoanDisbursementDetails) obj;
if (loanDisbursementDetails.principal.equals(this.principal)
&& loanDisbursementDetails.expectedDisbursementDate.equals(this.expectedDisbursementDate)) {
&& loanDisbursementDetails.expectedDisbursementDate.compareTo(this.expectedDisbursementDate) == 0 ? Boolean.TRUE
: Boolean.FALSE) {
return true;
}
return false;
@@ -706,13 +706,17 @@ public class SavingsAccountCharge extends AbstractPersistableCustom {
return Objects.equals(penaltyCharge, that.penaltyCharge) && Objects.equals(paid, that.paid) && Objects.equals(waived, that.waived)
&& Objects.equals(status, that.status) && Objects.equals(savingsAccount, that.savingsAccount)
&& Objects.equals(charge, that.charge) && Objects.equals(chargeTime, that.chargeTime)
&& Objects.equals(dueDate, that.dueDate) && Objects.equals(feeOnMonth, that.feeOnMonth)
&& Objects.equals(feeOnDay, that.feeOnDay) && Objects.equals(feeInterval, that.feeInterval)
&& Objects.equals(chargeCalculation, that.chargeCalculation) && Objects.equals(percentage, that.percentage)
&& Objects.equals(amountPercentageAppliedTo, that.amountPercentageAppliedTo) && Objects.equals(amount, that.amount)
&& Objects.equals(amountPaid, that.amountPaid) && Objects.equals(amountWaived, that.amountWaived)
&& Objects.equals(amountWrittenOff, that.amountWrittenOff) && Objects.equals(amountOutstanding, that.amountOutstanding)
&& Objects.equals(inactivationDate, that.inactivationDate);
&& dueDate.compareTo(that.dueDate) == 0
? Boolean.TRUE
: Boolean.FALSE && Objects.equals(feeOnMonth, that.feeOnMonth) && Objects.equals(feeOnDay, that.feeOnDay)
&& Objects.equals(feeInterval, that.feeInterval)
&& Objects.equals(chargeCalculation, that.chargeCalculation) && Objects.equals(percentage, that.percentage)
&& Objects.equals(amountPercentageAppliedTo, that.amountPercentageAppliedTo)
&& Objects.equals(amount, that.amount) && Objects.equals(amountPaid, that.amountPaid)
&& Objects.equals(amountWaived, that.amountWaived)
&& Objects.equals(amountWrittenOff, that.amountWrittenOff)
&& Objects.equals(amountOutstanding, that.amountOutstanding)
&& inactivationDate.compareTo(that.inactivationDate) == 0 ? Boolean.TRUE : Boolean.FALSE;
}
@Override
@@ -215,7 +215,7 @@ public class ShareAccount extends AbstractPersistableCustom {
public boolean setSubmittedDate(final Date submittedDate) {
boolean toReturn = false;
if (!this.submittedDate.equals(submittedDate)) {
if (this.submittedDate.compareTo(submittedDate) == 0 ? Boolean.FALSE : Boolean.TRUE) {
this.submittedDate = submittedDate;
toReturn = true;
}
@@ -224,7 +224,7 @@ public class ShareAccount extends AbstractPersistableCustom {
public boolean setApprovedDate(final Date approvedDate) {
boolean toReturn = false;
if (!this.approvedDate.equals(approvedDate)) {
if (this.approvedDate.compareTo(approvedDate) == 0 ? Boolean.FALSE : Boolean.TRUE) {
this.approvedDate = approvedDate;
toReturn = true;
}
@@ -520,10 +520,11 @@ public class ShareAccount extends AbstractPersistableCustom {
public ShareAccountTransaction getShareAccountTransaction(final ShareAccountTransaction transaction) {
ShareAccountTransaction returnTrans = null;
for (ShareAccountTransaction tran : this.shareAccountTransactions) {
if (tran.getPurchasedDate().equals(transaction.getPurchasedDate()) && tran.getTotalShares().equals(transaction.getTotalShares())
&& tran.getPurchasePrice().compareTo(transaction.getPurchasePrice()) == 0 ? Boolean.TRUE
: Boolean.FALSE && tran.getTransactionStatus().equals(transaction.getTransactionStatus())
&& tran.getTransactionType().equals(transaction.getTransactionType())) {
if (tran.getPurchasedDate().compareTo(transaction.getPurchasedDate()) == 0 ? Boolean.TRUE
: Boolean.FALSE && tran.getTotalShares().equals(transaction.getTotalShares())
&& tran.getPurchasePrice().compareTo(transaction.getPurchasePrice()) == 0 ? Boolean.TRUE
: Boolean.FALSE && tran.getTransactionStatus().equals(transaction.getTransactionStatus())
&& tran.getTransactionType().equals(transaction.getTransactionType())) {
returnTrans = tran;
break;
}
@@ -407,7 +407,7 @@ public class ShareProduct extends AbstractAuditableCustom {
if (this.marketPrice != null && !this.marketPrice.isEmpty()) {
for (ShareProductMarketPrice data : this.marketPrice) {
Date futureDate = data.getStartDate();
if (currentDate.equals(futureDate) || currentDate.after(futureDate)) {
if (currentDate.compareTo(futureDate) == 0 ? Boolean.TRUE : Boolean.FALSE || currentDate.after(futureDate)) {
marketValue = data.getPrice();
}
}