FINERACT-2346: Refractor, Minor Sonar fixes and remove some deprecated code

This commit is contained in:
Aman-Mittal
2025-12-01 19:11:59 +01:00
committed by Adam Saghy
parent 73d8659390
commit 00e9ac8320
17 changed files with 83 additions and 123 deletions
@@ -57,7 +57,7 @@ public enum GLAccountJsonInputParams {
@Override
public String toString() {
return name().toString().replaceAll("_", " ");
return name().replace("_", " ");
}
public String getValue() {
@@ -116,7 +116,7 @@ public enum GLAccountType {
@Override
public String toString() {
return name().toString();
return name();
}
public boolean isAssetType() {
@@ -64,7 +64,7 @@ public abstract class IdTypeResolver {
}
public static String formatIdType(String idType) {
return idType == null ? null : idType.replaceAll("-", "_").toUpperCase();
return idType == null ? null : idType.replace("-", "_").toUpperCase();
}
public static RuntimeException resolveFailed(String idType, Exception e) {
@@ -54,17 +54,17 @@ public class IdempotencyStoreFilter extends OncePerRequestFilter {
extractIdempotentKeyFromHttpServletRequest(request).ifPresent(idempotentKey -> fineractRequestContextHolder
.setAttribute(SynchronousCommandProcessingService.IDEMPOTENCY_KEY_ATTRIBUTE, idempotentKey, request));
filterChain.doFilter(request, wrapper.getValue() != null ? wrapper.getValue() : response);
filterChain.doFilter(request, wrapper.get() != null ? wrapper.get() : response);
Optional<Long> commandId = helper.getCommandId(request);
boolean isSuccessWithoutStored = commandId.isPresent() && wrapper.getValue() != null && helper.isStoreIdempotencyKey(request)
boolean isSuccessWithoutStored = commandId.isPresent() && wrapper.get() != null && helper.isStoreIdempotencyKey(request)
&& helper.isAllowedContentTypeResponse(response);
if (isSuccessWithoutStored) {
helper.storeCommandResult(response.getStatus(), Optional.ofNullable(wrapper.getValue())
helper.storeCommandResult(response.getStatus(), Optional.ofNullable(wrapper.get())
.map(ContentCachingResponseWrapper::getContentAsByteArray).map(s -> new String(s, StandardCharsets.UTF_8)).orElse(null),
commandId.get());
}
if (wrapper.getValue() != null) {
wrapper.getValue().copyBodyToResponse();
if (wrapper.get() != null) {
wrapper.get().copyBodyToResponse();
}
}
@@ -642,7 +642,7 @@ public class JsonParserHelper {
// http://bugs.sun.com/view_bug.do?bug_id=4510618
final char groupingSeparator = symbols.getGroupingSeparator();
if (groupingSeparator == '\u00a0') {
source = source.replaceAll(" ", Character.toString('\u00a0'));
source = source.replace(" ", Character.toString('\u00a0'));
}
final Number parsedNumber = df.parse(source);
@@ -727,9 +727,8 @@ public class JsonParserHelper {
// http://bugs.sun.com/view_bug.do?bug_id=4510618
final char groupingSeparator = symbols.getGroupingSeparator();
if (groupingSeparator == '\u00a0') {
source = source.replaceAll(" ", Character.toString('\u00a0'));
source = source.replace(" ", Character.toString('\u00a0'));
}
final NumberStyleFormatter numberFormatter = new NumberStyleFormatter();
final Number parsedNumber = numberFormatter.parse(source, clientApplicationLocale);
if (parsedNumber instanceof BigDecimal) {
@@ -41,16 +41,11 @@ public enum LegalForm {
public static LegalForm fromInt(final Integer type) {
LegalForm legalForm = null;
switch (type) {
case 1:
legalForm = LegalForm.PERSON;
break;
case 2:
legalForm = LegalForm.ENTITY;
break;
}
return legalForm;
return switch (type) {
case 1 -> LegalForm.PERSON;
case 2 -> LegalForm.ENTITY;
default -> null;
};
}
public boolean isPerson() {