equals -> equals by key

This commit is contained in:
akulikov 2023-04-27 12:37:24 +03:00
parent 2f369d6ea1
commit 202feebf0c
2 changed files with 6 additions and 9 deletions

View file

@ -53,7 +53,7 @@ public class AccountValidationConfig {
Company.class,
AccountError.RequiredFieldEmpty,
AccountError.CompanyNotFound,
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive),
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive),
FieldRequiredRule.instance("account",
CorrespondentAccountNewRequest::getAccount,
AccountError.RequiredFieldEmpty,
@ -74,8 +74,7 @@ public class AccountValidationConfig {
AccountError.RequiredFieldEmpty,
false,
statusValue -> {
if (statusValue == null || AccountStatus.ACTIVE.getKey().equalsIgnoreCase(statusValue))
return null;
if (statusValue == null || AccountStatus.ACTIVE.equalsByKey(statusValue)) return null;
return AccountError.WrongFieldValue;
}),
EnumPresentRule.instance("accountType",
@ -129,7 +128,7 @@ public class AccountValidationConfig {
AccountError.CompanyNotFound,
false,
company -> {
IErrorEnumId error = WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive;
IErrorEnumId error = WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive;
error = Objects.equals(company.getId(), correspondentAccountUpdateRequest.getCompanyId()) ? error : AccountError.WrongFieldValue;
return error;
}),

View file

@ -53,7 +53,7 @@ public class BankAccountValidationConfig {
Company.class,
AccountError.RequiredFieldEmpty,
AccountError.CompanyNotFound,
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive),
company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive),
FieldRequiredRule.instance("account",
BankAccountNewRequest::getAccount,
AccountError.RequiredFieldEmpty,
@ -119,8 +119,7 @@ public class BankAccountValidationConfig {
);
Account account = accountImdg.getSingleObjectByID(accountId);
if (account == null) return AccountError.AccountNotFound;
if (!AccountStatus.ACTIVE.getKey().equalsIgnoreCase(account.getStatus()))
return AccountError.AccountNotActive;
if (!AccountStatus.ACTIVE.equalsByKey(account.getStatus())) return AccountError.AccountNotActive;
return null;
}),
EnumPresentRule.instance("currency",
@ -164,8 +163,7 @@ public class BankAccountValidationConfig {
);
Account account = accountImdg.getSingleObjectByID(accountId);
if (account == null) return AccountError.AccountNotFound;
if (!AccountStatus.ACTIVE.getKey().equalsIgnoreCase(account.getStatus()))
return AccountError.AccountNotActive;
if (!AccountStatus.ACTIVE.equalsByKey(account.getStatus())) return AccountError.AccountNotActive;
return null;
})
);