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

View file

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