FINERACT-2326: Refractor redundant and some deprecated code as per new Java 21 style

This commit is contained in:
Aman-Mittal
2025-12-08 13:49:44 +01:00
committed by Adam Saghy
parent 399789ba42
commit dce3c66def
29 changed files with 117 additions and 232 deletions
@@ -70,25 +70,14 @@ public enum ChargeCalculationType {
}
public static ChargeCalculationType fromInt(final Integer chargeCalculation) {
ChargeCalculationType chargeCalculationType = ChargeCalculationType.INVALID;
switch (chargeCalculation) {
case 1:
chargeCalculationType = FLAT;
break;
case 2:
chargeCalculationType = PERCENT_OF_AMOUNT;
break;
case 3:
chargeCalculationType = PERCENT_OF_AMOUNT_AND_INTEREST;
break;
case 4:
chargeCalculationType = PERCENT_OF_INTEREST;
break;
case 5:
chargeCalculationType = PERCENT_OF_DISBURSEMENT_AMOUNT;
break;
}
return chargeCalculationType;
return switch (chargeCalculation) {
case 1 -> FLAT;
case 2 -> PERCENT_OF_AMOUNT;
case 3 -> PERCENT_OF_AMOUNT_AND_INTEREST;
case 4 -> PERCENT_OF_INTEREST;
case 5 -> PERCENT_OF_DISBURSEMENT_AMOUNT;
default -> INVALID;
};
}
public boolean isPercentageOfAmount() {
@@ -56,36 +56,21 @@ public final class FeignParts {
}
String ext = fileName.substring(dotPos + 1).toLowerCase();
switch (ext) {
case "jpg":
case "jpeg":
return "image/jpeg";
case "png":
return "image/png";
case "tif":
case "tiff":
return "image/tiff";
case "gif":
return "image/gif";
case "pdf":
return "application/pdf";
case "docx":
return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
case "doc":
return "application/msword";
case "xlsx":
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
case "xls":
return "application/vnd.ms-excel";
case "odt":
return "application/vnd.oasis.opendocument.text";
case "ods":
return "application/vnd.oasis.opendocument.spreadsheet";
case "txt":
return "text/plain";
default:
return "application/octet-stream";
}
return switch (ext) {
case "jpg", "jpeg" -> "image/jpeg";
case "png" -> "image/png";
case "tif", "tiff" -> "image/tiff";
case "gif" -> "image/gif";
case "pdf" -> "application/pdf";
case "docx" -> "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
case "doc" -> "application/msword";
case "xlsx" -> "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
case "xls" -> "application/vnd.ms-excel";
case "odt" -> "application/vnd.oasis.opendocument.text";
case "ods" -> "application/vnd.oasis.opendocument.spreadsheet";
case "txt" -> "text/plain";
default -> "application/octet-stream";
};
}
/**
@@ -24,8 +24,8 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import java.util.Map;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.fineract.infrastructure.core.exception.ErrorHandler;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -43,8 +43,9 @@ public class DefaultExceptionMapper implements FineractExceptionMapper, Exceptio
@Override
public Response toResponse(RuntimeException exception) {
log.warn("Exception occurred", ErrorHandler.findMostSpecificException(exception));
return Response.status(SC_INTERNAL_SERVER_ERROR)
.entity(Map.of("Exception", ObjectUtils.defaultIfNull(exception.getMessage(), "No error message available")))
.entity(Map.of("Exception", Objects.requireNonNullElse(exception.getMessage(), "No error message available")))
.type(MediaType.APPLICATION_JSON).build();
}
}
@@ -98,9 +98,8 @@ public class DataSourcePerTenantServiceFactory {
// https://github.com/brettwooldridge/HikariCP/wiki/MBean-(JMX)-Monitoring-and-Management
config.setRegisterMbeans(true);
meterRegistry.ifPresent(registry -> {
config.setMetricsTrackerFactory(new TenantConnectionPoolMetricsTrackerFactory(tenant.getTenantIdentifier(), registry));
});
meterRegistry.ifPresent(registry -> config
.setMetricsTrackerFactory(new TenantConnectionPoolMetricsTrackerFactory(tenant.getTenantIdentifier(), registry)));
// https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
// These are the properties for each Tenant DB; the same configuration
@@ -59,15 +59,11 @@ public enum DaysInMonthType {
public static DaysInMonthType fromInt(final Integer type) {
DaysInMonthType repaymentFrequencyType = DaysInMonthType.INVALID;
if (type != null) {
switch (type) {
case 1:
repaymentFrequencyType = DaysInMonthType.ACTUAL;
break;
case 30:
repaymentFrequencyType = DaysInMonthType.DAYS_30;
break;
}
repaymentFrequencyType = switch (type) {
case 1 -> DaysInMonthType.ACTUAL;
case 30 -> DaysInMonthType.DAYS_30;
default -> repaymentFrequencyType;
};
}
return repaymentFrequencyType;
}
@@ -63,20 +63,13 @@ public enum DaysInYearType {
public static DaysInYearType fromInt(final Integer type) {
DaysInYearType repaymentFrequencyType = DaysInYearType.INVALID;
if (type != null) {
switch (type) {
case 1:
repaymentFrequencyType = DaysInYearType.ACTUAL;
break;
case 360:
repaymentFrequencyType = DaysInYearType.DAYS_360;
break;
case 364:
repaymentFrequencyType = DaysInYearType.DAYS_364;
break;
case 365:
repaymentFrequencyType = DaysInYearType.DAYS_365;
break;
}
repaymentFrequencyType = switch (type) {
case 1 -> DaysInYearType.ACTUAL;
case 360 -> DaysInYearType.DAYS_360;
case 364 -> DaysInYearType.DAYS_364;
case 365 -> DaysInYearType.DAYS_365;
default -> repaymentFrequencyType;
};
}
return repaymentFrequencyType;
}
@@ -42,7 +42,7 @@ public class DelinquencyEffectivePauseHelperImpl implements DelinquencyEffective
.collect(Collectors.groupingBy(LoanDelinquencyAction::getAction));
List<LoanDelinquencyActionData> effective = new ArrayList<>();
List<LoanDelinquencyAction> pauses = partitioned.get(DelinquencyAction.PAUSE);
if (pauses != null && pauses.size() > 0) {
if (pauses != null && !pauses.isEmpty()) {
for (LoanDelinquencyAction loanDelinquencyAction : pauses) {
Optional<LoanDelinquencyAction> resume = findMatchingResume(loanDelinquencyAction, partitioned.get(RESUME));
LoanDelinquencyActionData loanDelinquencyActionData = new LoanDelinquencyActionData(loanDelinquencyAction);
@@ -91,7 +91,7 @@ public class DelinquencyEffectivePauseHelperImpl implements DelinquencyEffective
}
private Optional<LoanDelinquencyAction> findMatchingResume(LoanDelinquencyAction pause, List<LoanDelinquencyAction> resumes) {
if (resumes != null && resumes.size() > 0) {
if (resumes != null && !resumes.isEmpty()) {
for (LoanDelinquencyAction resume : resumes) {
if (!pause.getStartDate().isAfter(resume.getStartDate()) && !resume.getStartDate().isAfter(pause.getEndDate())) {
return Optional.of(resume);
@@ -337,11 +337,9 @@ public class DelinquencyReadPlatformServiceImpl implements DelinquencyReadPlatfo
isCurrentDateBeforeInstallmentAndLoanPeriod = DateUtils.isEqual(currentBusinessDate, installment.getDueDate())
&& DateUtils.isBefore(currentBusinessDate, expectedMaturityDate);
}
if (isCurrentDateBeforeInstallmentAndLoanPeriod) {
if (installment.isNotFullyPaidOff()) {
nextUnpaidInstallmentDate = installment.getDueDate();
break;
}
if (isCurrentDateBeforeInstallmentAndLoanPeriod && installment.isNotFullyPaidOff()) {
nextUnpaidInstallmentDate = installment.getDueDate();
break;
}
}
return nextUnpaidInstallmentDate;
@@ -127,7 +127,7 @@ public class DelinquencyWritePlatformServiceHelper {
changes.put("current", loanDelinquencyTag.getDelinquencyRange());
}
}
if (loanDelinquencyTagHistory.size() > 0) {
if (!loanDelinquencyTagHistory.isEmpty()) {
this.loanDelinquencyTagRepository.saveAllAndFlush(loanDelinquencyTagHistory);
// if installment level delinquency is enabled event will be raised at installment level calculation, no
// need to raise the event here
@@ -173,10 +173,10 @@ public class DelinquencyWritePlatformServiceHelper {
private void removeDelinquencyTagsForNonExistingInstallments(Long loanId) {
List<LoanInstallmentDelinquencyTag> currentLoanInstallmentDelinquencyTags = loanInstallmentDelinquencyTagRepository
.findByLoanId(loanId);
if (currentLoanInstallmentDelinquencyTags != null && currentLoanInstallmentDelinquencyTags.size() > 0) {
if (currentLoanInstallmentDelinquencyTags != null && !currentLoanInstallmentDelinquencyTags.isEmpty()) {
List<Long> loanInstallmentTagsForDelete = currentLoanInstallmentDelinquencyTags.stream()
.filter(tag -> tag.getInstallment() == null).map(tag -> tag.getId()).toList();
if (loanInstallmentTagsForDelete.size() > 0) {
if (!loanInstallmentTagsForDelete.isEmpty()) {
loanInstallmentDelinquencyTagRepository.deleteAllLoanInstallmentsTagsByIds(loanInstallmentTagsForDelete);
}
}
@@ -260,7 +260,7 @@ public class DelinquencyWritePlatformServiceHelper {
}
if (installmentDelinquencyTags.size() > 0) {
if (!installmentDelinquencyTags.isEmpty()) {
loanInstallmentDelinquencyTagRepository.saveAllAndFlush(installmentDelinquencyTags);
}
return isDelinquencyRangeChanged;
@@ -291,7 +291,7 @@ public class DelinquencyWritePlatformServiceImpl implements DelinquencyWritePlat
@Override
public void cleanLoanDelinquencyTags(Loan loan) {
List<LoanDelinquencyTagHistory> loanDelinquencyTags = this.loanDelinquencyTagRepository.findByLoan(loan);
if (loanDelinquencyTags != null && loanDelinquencyTags.size() > 0) {
if (loanDelinquencyTags != null && !loanDelinquencyTags.isEmpty()) {
this.loanDelinquencyTagRepository.deleteAll(loanDelinquencyTags);
}
}
@@ -362,9 +362,7 @@ public class DelinquencyWritePlatformServiceImpl implements DelinquencyWritePlat
private void setDelinquencyBucketMappings(DelinquencyBucket delinquencyBucket, DelinquencyBucketData data) {
List<Long> rangeIds = new ArrayList<>();
data.getRanges().forEach(dataRange -> {
rangeIds.add(dataRange.getId());
});
data.getRanges().forEach(dataRange -> rangeIds.add(dataRange.getId()));
List<DelinquencyRange> ranges = repositoryRange.findAllById(rangeIds);
validateDelinquencyRanges(ranges);
@@ -383,11 +381,9 @@ public class DelinquencyWritePlatformServiceImpl implements DelinquencyWritePlat
DelinquencyRange prevDelinquencyRange = null;
for (DelinquencyRange delinquencyRange : ranges) {
if (prevDelinquencyRange != null) {
if (isOverlapped(prevDelinquencyRange, delinquencyRange)) {
final String errorMessage = "The delinquency ranges age days values are overlaped";
throw new DelinquencyBucketAgesOverlapedException(errorMessage, prevDelinquencyRange, delinquencyRange);
}
if (prevDelinquencyRange != null && isOverlapped(prevDelinquencyRange, delinquencyRange)) {
final String errorMessage = "The delinquency ranges age days values are overlaped";
throw new DelinquencyBucketAgesOverlapedException(errorMessage, prevDelinquencyRange, delinquencyRange);
}
prevDelinquencyRange = delinquencyRange;
}
@@ -153,7 +153,7 @@ public class DefaultLoanLifecycleStateMachine implements LoanLifecycleStateMachi
}
break;
case LOAN_CHARGE_PAYMENT:
case LOAN_REPAYMENT_OR_WAIVER:
case LOAN_REPAYMENT_OR_WAIVER, LOAN_CHARGEBACK:
if (anyOfAllowedWhenComingFrom(from, LoanStatus.CLOSED_OBLIGATIONS_MET, LoanStatus.OVERPAID)) {
newState = activeTransition();
}
@@ -217,11 +217,6 @@ public class DefaultLoanLifecycleStateMachine implements LoanLifecycleStateMachi
newState = activeTransition();
}
break;
case LOAN_CHARGEBACK:
if (anyOfAllowedWhenComingFrom(from, LoanStatus.CLOSED_OBLIGATIONS_MET, LoanStatus.OVERPAID)) {
newState = activeTransition();
}
break;
case LOAN_CHARGE_ADJUSTMENT:
if (from.hasStateOf(LoanStatus.CLOSED_OBLIGATIONS_MET)) {
newState = overpaidTransition();
@@ -86,7 +86,7 @@ public class CreditAllocationsValidator {
}
private boolean hasLoanProductCreditAllocationRule(List<LoanProductCreditAllocationRule> rules) {
return rules != null && rules.size() > 0;
return rules != null && !rules.isEmpty();
}
private void raiseValidationError(String globalisationMessageCode, String msg) {
@@ -94,9 +94,7 @@ public class CreditAllocationsJsonParserTest {
private static List<Pair<Integer, AllocationType>> createAllocationTypeList() {
AtomicInteger i = new AtomicInteger(1);
List<Pair<Integer, AllocationType>> list = EnumSet.allOf(AllocationType.class).stream().map(p -> Pair.of(i.getAndIncrement(), p))
.toList();
return list;
return EnumSet.allOf(AllocationType.class).stream().map(p -> Pair.of(i.getAndIncrement(), p)).toList();
}
public Map<String, Object> createCreditAllocationEntry(String transactionType, List<String> orderedRules) {
@@ -117,9 +115,8 @@ public class CreditAllocationsJsonParserTest {
private JsonCommand createJsonCommand(Map<String, Object> jsonMap) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonMap);
JsonCommand command = JsonCommand.from(json, JsonParser.parseString(json), fromJsonHelper, null, 1L, 2L, 3L, 4L, null, null, null,
null, null, null, null, null, null);
return command;
return JsonCommand.from(json, JsonParser.parseString(json), fromJsonHelper, null, 1L, 2L, 3L, 4L, null, null, null, null, null,
null, null, null, null);
}
}
@@ -68,8 +68,7 @@ public enum EntityAccountType {
}
public static EntityAccountType fromInt(final int i) {
final EntityAccountType type = intToEnumMap.get(Integer.valueOf(i));
return type;
return intToEnumMap.get(i);
}
public static int getMinValue() {
@@ -82,7 +81,7 @@ public enum EntityAccountType {
@Override
public String toString() {
return name().toString();
return name();
}
public boolean isClientAccount() {
@@ -94,9 +94,7 @@ public final class EmailConfigurationValidator {
public boolean isValidEmail(String email) {
// this is the easiest check
if (email == null) {
return false;
} else if (email.endsWith(".")) {
if (email == null || email.endsWith(".")) {
return false;
}
@@ -104,10 +102,6 @@ public final class EmailConfigurationValidator {
Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
// check if the Matcher matches the email pattern
if (!emailMatcher.matches()) {
return false;
}
return true;
return emailMatcher.matches();
}
}
@@ -262,11 +262,7 @@ public final class EmailDataValidator {
Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
// check if the Matcher matches the email pattern
if (!emailMatcher.matches()) {
return false;
}
return true;
return emailMatcher.matches();
}
/**
@@ -36,17 +36,12 @@ public enum EmailCampaignStatus {
public static EmailCampaignStatus fromInt(final Integer statusValue) {
EmailCampaignStatus enumeration = EmailCampaignStatus.INVALID;
switch (statusValue) {
case 100:
enumeration = EmailCampaignStatus.PENDING;
break;
case 300:
enumeration = EmailCampaignStatus.ACTIVE;
break;
case 600:
enumeration = EmailCampaignStatus.CLOSED;
break;
}
enumeration = switch (statusValue) {
case 100 -> EmailCampaignStatus.PENDING;
case 300 -> EmailCampaignStatus.ACTIVE;
case 600 -> EmailCampaignStatus.CLOSED;
default -> enumeration;
};
return enumeration;
}
@@ -41,19 +41,12 @@ public enum EmailCampaignType {
}
public static EmailCampaignType fromInt(final Integer typeValue) {
EmailCampaignType type = null;
switch (typeValue) {
case 1:
type = DIRECT;
break;
case 2:
type = SCHEDULE;
break;
case 3:
type = TRIGGERED;
break;
}
return type;
return switch (typeValue) {
case 1 -> DIRECT;
case 2 -> SCHEDULE;
case 3 -> TRIGGERED;
default -> null;
};
}
public boolean isDirect() {
@@ -32,20 +32,13 @@ public enum EmailMessageStatusType {
public static EmailMessageStatusType fromInt(final Integer statusValue) {
EmailMessageStatusType enumeration = EmailMessageStatusType.INVALID;
switch (statusValue) {
case 100:
enumeration = EmailMessageStatusType.PENDING;
break;
case 200:
enumeration = EmailMessageStatusType.SENT;
break;
case 300:
enumeration = EmailMessageStatusType.DELIVERED;
break;
case 400:
enumeration = EmailMessageStatusType.FAILED;
break;
}
enumeration = switch (statusValue) {
case 100 -> EmailMessageStatusType.PENDING;
case 200 -> EmailMessageStatusType.SENT;
case 300 -> EmailMessageStatusType.DELIVERED;
case 400 -> EmailMessageStatusType.FAILED;
default -> enumeration;
};
return enumeration;
}
@@ -117,8 +117,6 @@ public class EmailCampaignDomainServiceImpl implements EmailCampaignDomainServic
}
private List<EmailCampaign> retrieveEmailCampaigns(String paramValue) {
List<EmailCampaign> emailCampaigns = emailCampaignRepository.findActiveEmailCampaigns("%" + paramValue + "%",
SmsCampaignTriggerType.TRIGGERED.getValue());
return emailCampaigns;
return emailCampaignRepository.findActiveEmailCampaigns("%" + paramValue + "%", SmsCampaignTriggerType.TRIGGERED.getValue());
}
}
@@ -62,7 +62,7 @@ public final class EmailMessageJobEmailServiceImpl implements EmailMessageJobEma
mimeMessageHelper.setText(emailMessageWithAttachmentData.getText(), true);
mimeMessageHelper.setSubject(emailMessageWithAttachmentData.getSubject());
final List<File> attachments = emailMessageWithAttachmentData.getAttachments();
if (attachments != null && attachments.size() > 0) {
if (attachments != null && !attachments.isEmpty()) {
for (final File attachment : attachments) {
if (attachment != null) {
mimeMessageHelper.addAttachment(attachment.getName(), attachment);
@@ -36,7 +36,7 @@ public class DeleteDatatableCommandHandler implements NewCommandSourceHandler {
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
final String datatableName = command.getUrl().replaceAll("/datatables/", "");
final String datatableName = command.getUrl().replace("/datatables/", "");
datatableWriteService.deleteDatatable(datatableName);
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withResourceIdAsString(datatableName).build();
}
@@ -121,10 +121,10 @@ public class EntityDatatableChecksReadPlatformServiceImpl implements EntityDatat
tableRequiredBeforeAction = this.entityDatatableChecksRepository.findByEntityStatusAndProduct(entity, status, productId);
}
if (tableRequiredBeforeAction == null || tableRequiredBeforeAction.size() < 1) {
if (tableRequiredBeforeAction == null || tableRequiredBeforeAction.isEmpty()) {
tableRequiredBeforeAction = this.entityDatatableChecksRepository.findByEntityStatusAndNoProduct(entity, status);
}
if (tableRequiredBeforeAction != null && tableRequiredBeforeAction.size() > 0) {
if (tableRequiredBeforeAction != null && !tableRequiredBeforeAction.isEmpty()) {
List<DatatableData> ret = new ArrayList<>();
for (EntityDatatableChecks t : tableRequiredBeforeAction) {
ret.add(this.datatableReadService.retrieveDatatable(t.getDatatableName()));
@@ -37,34 +37,28 @@ public class DropdownReadPlatformServiceImpl implements DropdownReadPlatformServ
@Override
public List<EnumOptionData> retrievePeriodFrequencyTypeOptions() {
final List<EnumOptionData> loanTermFrequencyOptions = Arrays.asList(termFrequencyType(PeriodFrequencyType.DAYS, "frequency"),
return Arrays.asList(termFrequencyType(PeriodFrequencyType.DAYS, "frequency"),
termFrequencyType(PeriodFrequencyType.WEEKS, "frequency"), termFrequencyType(PeriodFrequencyType.MONTHS, "frequency"),
termFrequencyType(PeriodFrequencyType.YEARS, "frequency"), termFrequencyType(PeriodFrequencyType.WHOLE_TERM, "frequency"));
return loanTermFrequencyOptions;
}
@Override
public List<EnumOptionData> retrieveConditionTypeOptions() {
final List<EnumOptionData> loanTermFrequencyOptions = Arrays.asList(conditionType(ConditionType.EQUAL, "condition"),
conditionType(ConditionType.NOT_EQUAL, "condition"), conditionType(ConditionType.GRETERTHAN, "condition"),
conditionType(ConditionType.LESSTHAN, "condition"));
return loanTermFrequencyOptions;
return Arrays.asList(conditionType(ConditionType.EQUAL, "condition"), conditionType(ConditionType.NOT_EQUAL, "condition"),
conditionType(ConditionType.GRETERTHAN, "condition"), conditionType(ConditionType.LESSTHAN, "condition"));
}
@Override
public List<EnumOptionData> retrieveDaysInMonthTypeOptions() {
final List<EnumOptionData> daysInMonthTypeOptions = Arrays.asList(daysInMonthType(DaysInMonthType.ACTUAL),
daysInMonthType(DaysInMonthType.DAYS_30));
return daysInMonthTypeOptions;
return Arrays.asList(daysInMonthType(DaysInMonthType.ACTUAL), daysInMonthType(DaysInMonthType.DAYS_30));
}
@Override
public List<EnumOptionData> retrieveDaysInYearTypeOptions() {
final List<EnumOptionData> daysInYearTypeOptions = Arrays.asList(daysInYearType(DaysInYearType.ACTUAL),
daysInYearType(DaysInYearType.DAYS_360), daysInYearType(DaysInYearType.DAYS_364), daysInYearType(DaysInYearType.DAYS_365));
return daysInYearTypeOptions;
return Arrays.asList(daysInYearType(DaysInYearType.ACTUAL), daysInYearType(DaysInYearType.DAYS_360),
daysInYearType(DaysInYearType.DAYS_364), daysInYearType(DaysInYearType.DAYS_365));
}
}
@@ -440,9 +440,7 @@ public class DepositAccountAssembler {
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal,
adjustAdvanceTowardsFuturePayments);
final DepositAccountRecurringDetail depositAccountRecurringDetail = DepositAccountRecurringDetail.createNew(recurringDepositAmount,
depositRecurringDetail, null, isCalendarInherited);
return depositAccountRecurringDetail;
return DepositAccountRecurringDetail.createNew(recurringDepositAmount, depositRecurringDetail, null, isCalendarInherited);
}
public Collection<SavingsAccountTransactionDTO> assembleBulkMandatorySavingsAccountTransactionDTOs(final JsonCommand command,
@@ -747,16 +747,12 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
private void checkClientOrGroupActive(final SavingsAccount account) {
final Client client = account.getClient();
if (client != null) {
if (client.isNotActive()) {
throw new ClientNotActiveException(client.getId());
}
if (client != null && client.isNotActive()) {
throw new ClientNotActiveException(client.getId());
}
final Group group = account.group();
if (group != null) {
if (group.isNotActive()) {
throw new GroupNotActiveException(group.getId());
}
if (group != null && group.isNotActive()) {
throw new GroupNotActiveException(group.getId());
}
}
@@ -729,19 +729,17 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
private void checkClientOrGroupActive(final SavingsAccount account) {
final Client client = account.getClient();
if (client != null) {
if (client.isNotActive()) {
throw new ClientNotActiveException(client.getId());
}
if (client != null && client.isNotActive()) {
throw new ClientNotActiveException(client.getId());
}
final Group group = account.group();
if (group != null) {
if (group.isNotActive()) {
if (group.isCenter()) {
throw new CenterNotActiveException(group.getId());
}
throw new GroupNotActiveException(group.getId());
if (group != null && group.isNotActive()) {
if (group.isCenter()) {
throw new CenterNotActiveException(group.getId());
}
throw new GroupNotActiveException(group.getId());
}
}
}
@@ -67,8 +67,7 @@ public class DeviceRegistrationApiResource {
Long clientId = json.get(DeviceRegistrationApiConstants.clientIdParamName).getAsLong();
String registrationId = json.get(DeviceRegistrationApiConstants.registrationIdParamName).getAsString();
DeviceRegistration deviceRegistration = this.deviceRegistrationWritePlatformService.registerDevice(clientId, registrationId);
String response = gson.toJson(deviceRegistration.getId());
return response;
return gson.toJson(deviceRegistration.getId());
}
@GET
@@ -125,8 +124,7 @@ public class DeviceRegistrationApiResource {
String registrationId = json.get(DeviceRegistrationApiConstants.registrationIdParamName).getAsString();
DeviceRegistration deviceRegistration = this.deviceRegistrationWritePlatformService.updateDeviceRegistration(id, clientId,
registrationId);
String response = gson.toJson(deviceRegistration.getId());
return response;
return gson.toJson(deviceRegistration.getId());
}
@DELETE
@@ -299,10 +299,7 @@ public class DepositProductAssembler {
}
}
DepositPreClosureDetail preClosureDetail = DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestType);
return preClosureDetail;
return DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
}
public DepositPreClosureDetail assemblePreClosureDetail(final JsonCommand command, DepositPreClosureDetail produPreClosureDetail) {
@@ -334,10 +331,7 @@ public class DepositProductAssembler {
preClosurePenalInterestType = preClosurePenalInterestOnTypeId == null ? null
: PreClosurePenalInterestOnType.fromInt(preClosurePenalInterestOnTypeId);
DepositPreClosureDetail preClosureDetail1 = DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestType);
return preClosureDetail1;
return DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
}
public DepositTermDetail assembleDepositTermDetail(final JsonCommand command) {
@@ -355,10 +349,8 @@ public class DepositProductAssembler {
final SavingsPeriodFrequencyType inMultiplesOfDepositTermType = (inMultiplesOfDepositTermTypeId == null) ? null
: SavingsPeriodFrequencyType.fromInt(inMultiplesOfDepositTermTypeId);
final DepositTermDetail depositTermDetail = DepositTermDetail.createFrom(minDepositTerm, maxDepositTerm, minDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType);
return depositTermDetail;
return DepositTermDetail.createFrom(minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType);
}
public DepositTermDetail assembleDepositTermDetail(final JsonCommand command, final DepositTermDetail prodDepositTermDetail) {
@@ -415,10 +407,8 @@ public class DepositProductAssembler {
final SavingsPeriodFrequencyType inMultiplesOfDepositTermType = (inMultiplesOfDepositTermTypeId == null) ? null
: SavingsPeriodFrequencyType.fromInt(inMultiplesOfDepositTermTypeId);
final DepositTermDetail depositTermDetail = DepositTermDetail.createFrom(minDepositTerm, maxDepositTerm, minDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType);
return depositTermDetail;
return DepositTermDetail.createFrom(minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType);
}
public DepositRecurringDetail assembleRecurringDetail(final JsonCommand command) {
@@ -438,10 +428,7 @@ public class DepositProductAssembler {
adjustAdvanceTowardsFuturePayments = false;
}
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal,
adjustAdvanceTowardsFuturePayments);
return depositRecurringDetail;
return DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal, adjustAdvanceTowardsFuturePayments);
}
public Set<Charge> assembleListOfSavingsProductCharges(final JsonCommand command, final String savingsProductCurrencyCode) {
@@ -510,10 +497,7 @@ public class DepositProductAssembler {
depositAmount = command.bigDecimalValueOfParameterNamed(depositAmountParamName);
}
final DepositProductAmountDetails depositRecurringDetail = new DepositProductAmountDetails(minDepositAmount, depositAmount,
maxDepositAmount);
return depositRecurringDetail;
return new DepositProductAmountDetails(minDepositAmount, depositAmount, maxDepositAmount);
}
public TaxGroup assembleTaxGroup(final JsonCommand command) {