FINERACT-822 enable ImmutableEnumChecker error
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
f8dee63114
commit
7c6b15e3bc
@@ -367,6 +367,7 @@ tasks.withType(JavaCompile) {
|
||||
"VarTypeName",
|
||||
"ArgumentSelectionDefectChecker",
|
||||
"CompareToZero",
|
||||
"ImmutableEnumChecker",
|
||||
"NarrowingCompoundAssignment",
|
||||
"MissingCasesInEnumSwitch",
|
||||
"ReferenceEquality",
|
||||
@@ -443,7 +444,8 @@ modernizer {
|
||||
|
||||
ignorePackages = []
|
||||
ignoreClassNamePatterns = [
|
||||
'.*AbstractPersistableCustom'
|
||||
'.*AbstractPersistableCustom',
|
||||
'.*EntityTables'
|
||||
]
|
||||
ignoreGeneratedClasses = true
|
||||
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
public enum CampaignType {
|
||||
INVALID(0, "campaignType.invalid"), SMS(1, "campaignType.sms"), NOTIFICATION(2, "campaignType.notification");
|
||||
|
||||
private Integer value;
|
||||
private String code;
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
private CampaignType(Integer value, String code) {
|
||||
this.value = value;
|
||||
|
||||
+2
-2
@@ -22,8 +22,8 @@ public enum EmailCampaignType {
|
||||
DIRECT(1,"emailCampaignStatusType.direct"),
|
||||
SCHEDULE(2,"emailCampaignStatusType.schedule");
|
||||
|
||||
private Integer value;
|
||||
private String code;
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
EmailCampaignType(Integer value, String code) {
|
||||
this.value = value;
|
||||
|
||||
+3
-3
@@ -24,9 +24,9 @@ public enum ScheduledEmailAttachmentFileFormat {
|
||||
PDF(2, "EmailAttachmentFileFormat.pdf", "pdf"),
|
||||
CSV(3, "EmailAttachmentFileFormat.csv", "csv");
|
||||
|
||||
private String code;
|
||||
private String value;
|
||||
private Integer id;
|
||||
private final String code;
|
||||
private final String value;
|
||||
private final Integer id;
|
||||
|
||||
ScheduledEmailAttachmentFileFormat(final Integer id, final String code, final String value) {
|
||||
this.value = value;
|
||||
|
||||
+3
-3
@@ -24,9 +24,9 @@ public enum ScheduledEmailStretchyReportParamDateOption {
|
||||
// YESTERDAY(2, "scheduledEmailStretchyReportParamDateOption.yesterday", "yesterday"),
|
||||
TOMORROW(3, "scheduledEmailStretchyReportParamDateOption.tomorrow", "tomorrow");
|
||||
|
||||
private String code;
|
||||
private String value;
|
||||
private Integer id;
|
||||
private final String code;
|
||||
private final String value;
|
||||
private final Integer id;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ public enum SmsCampaignTriggerType {
|
||||
INVALID(-1, "triggerType.invalid"), DIRECT(1, "triggerType.direct"), SCHEDULE(2, "triggerType.schedule"), TRIGGERED(3,
|
||||
"triggerType.triggered");
|
||||
|
||||
private Integer value;
|
||||
private String code;
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
private SmsCampaignTriggerType(Integer value, String code) {
|
||||
this.value = value;
|
||||
|
||||
+31
-30
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.dataqueries.data;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -26,45 +27,45 @@ import java.util.Map;
|
||||
public enum EntityTables {
|
||||
|
||||
CLIENT("m_client",
|
||||
new Integer[]{StatusEnum.CREATE.getCode(),
|
||||
StatusEnum.ACTIVATE.getCode(),
|
||||
StatusEnum.CLOSE.getCode()},
|
||||
"client_id"),
|
||||
ImmutableList.of(StatusEnum.CREATE.getCode(),
|
||||
StatusEnum.ACTIVATE.getCode(),
|
||||
StatusEnum.CLOSE.getCode()),
|
||||
"client_id"),
|
||||
LOAN("m_loan",
|
||||
new Integer[]{StatusEnum.CREATE.getCode(),
|
||||
StatusEnum.APPROVE.getCode(),
|
||||
StatusEnum.DISBURSE.getCode(),
|
||||
StatusEnum.WITHDRAWN.getCode(),
|
||||
StatusEnum.REJECTED.getCode(),
|
||||
StatusEnum.WRITE_OFF.getCode()},
|
||||
"loan_id"),
|
||||
ImmutableList.of(StatusEnum.CREATE.getCode(),
|
||||
StatusEnum.APPROVE.getCode(),
|
||||
StatusEnum.DISBURSE.getCode(),
|
||||
StatusEnum.WITHDRAWN.getCode(),
|
||||
StatusEnum.REJECTED.getCode(),
|
||||
StatusEnum.WRITE_OFF.getCode()),
|
||||
"loan_id"),
|
||||
GROUP("m_group",
|
||||
new Integer[]{StatusEnum.CREATE.getCode(),
|
||||
StatusEnum.ACTIVATE.getCode(),
|
||||
StatusEnum.CLOSE.getCode(),},
|
||||
"group_id"),
|
||||
ImmutableList.of(StatusEnum.CREATE.getCode(),
|
||||
StatusEnum.ACTIVATE.getCode(),
|
||||
StatusEnum.CLOSE.getCode()),
|
||||
"group_id"),
|
||||
SAVING("m_savings_account",
|
||||
new Integer[]{StatusEnum.CREATE.getCode(),
|
||||
StatusEnum.APPROVE.getCode(),
|
||||
StatusEnum.ACTIVATE.getCode(),
|
||||
StatusEnum.WITHDRAWN.getCode(),
|
||||
StatusEnum.REJECTED.getCode(),
|
||||
StatusEnum.CLOSE.getCode()},
|
||||
"savings_account_id");
|
||||
ImmutableList.of(StatusEnum.CREATE.getCode(),
|
||||
StatusEnum.APPROVE.getCode(),
|
||||
StatusEnum.ACTIVATE.getCode(),
|
||||
StatusEnum.WITHDRAWN.getCode(),
|
||||
StatusEnum.REJECTED.getCode(),
|
||||
StatusEnum.CLOSE.getCode()),
|
||||
"savings_account_id");
|
||||
|
||||
private static final Map<String, EntityTables> lookup = new HashMap<String, EntityTables>();
|
||||
static {
|
||||
for (EntityTables d : EntityTables.values())
|
||||
{ lookup.put(d.getName(), d);}
|
||||
{ lookup.put(d.getName(), d);}
|
||||
}
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private Integer[] codes;
|
||||
private final ImmutableList<Integer> codes;
|
||||
|
||||
private String foreignKeyColumnNameOnDatatable;
|
||||
private final String foreignKeyColumnNameOnDatatable;
|
||||
|
||||
private EntityTables(String name, Integer[] codes, String foreignKeyColumnNameOnDatatable) {
|
||||
private EntityTables(String name, ImmutableList<Integer> codes, String foreignKeyColumnNameOnDatatable) {
|
||||
this.name = name;
|
||||
this.codes = codes;
|
||||
this.foreignKeyColumnNameOnDatatable = foreignKeyColumnNameOnDatatable;
|
||||
@@ -82,14 +83,14 @@ public enum EntityTables {
|
||||
|
||||
}
|
||||
|
||||
public static Integer[] getStatus(String name) {
|
||||
public static ImmutableList<Integer> getStatus(String name) {
|
||||
if (lookup.get(name) != null) {
|
||||
return lookup.get(name).getCodes();
|
||||
}
|
||||
return new Integer[]{};
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
public Integer[] getCodes() {
|
||||
public ImmutableList<Integer> getCodes() {
|
||||
return this.codes;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -27,14 +27,14 @@ public enum StatusEnum {
|
||||
CREATE("create", 100), APPROVE("approve", 200), ACTIVATE("activate", 300), WITHDRAWN("withdraw", 400), REJECTED("reject", 500), CLOSE(
|
||||
"close", 600), WRITE_OFF("write off", 601), RESCHEDULE("reschedule", 602), OVERPAY("overpay", 700), DISBURSE("disburse", 800);
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
public Integer getCode() {
|
||||
private final Integer code;
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
private Integer code;
|
||||
|
||||
private StatusEnum(String name, Integer code) {
|
||||
|
||||
this.name = name;
|
||||
|
||||
+2
-2
@@ -73,7 +73,7 @@ public final class EntityDatatableChecksDataValidator {
|
||||
.isOneOfTheseStringValues(EntityTables.getEntitiesList());
|
||||
|
||||
final Integer status = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("status", element);
|
||||
final Object[] entityTablesStatuses = EntityTables.getStatus(entity);
|
||||
final Object[] entityTablesStatuses = EntityTables.getStatus(entity).toArray();
|
||||
|
||||
baseDataValidator.reset().parameter("status").value(status).isOneOfTheseValues(entityTablesStatuses);
|
||||
|
||||
@@ -98,4 +98,4 @@ public final class EntityDatatableChecksDataValidator {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.dataqueries.service;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@@ -151,7 +152,7 @@ public class EntityDatatableChecksReadPlatformServiceImpl implements EntityDatat
|
||||
|
||||
}
|
||||
|
||||
private List<DatatableCheckStatusData> getStatusList(Integer[] statuses) {
|
||||
private List<DatatableCheckStatusData> getStatusList(ImmutableList<Integer> statuses) {
|
||||
List<DatatableCheckStatusData> ret = new ArrayList<>();
|
||||
if (statuses != null) {
|
||||
for (Integer status : statuses) {
|
||||
@@ -216,4 +217,4 @@ public class EntityDatatableChecksReadPlatformServiceImpl implements EntityDatat
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import java.util.Map;
|
||||
public enum StorageType {
|
||||
FILE_SYSTEM(1), S3(2);
|
||||
|
||||
private Integer value;
|
||||
private final Integer value;
|
||||
|
||||
StorageType(final Integer value) {
|
||||
this.value = value;
|
||||
@@ -45,4 +45,4 @@ public enum StorageType {
|
||||
final StorageType type = intToEnumMap.get(Integer.valueOf(i));
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -29,9 +29,9 @@ public enum ReportMailingJobEmailAttachmentFileFormat {
|
||||
PDF(2, "ReportMailingJobEmailAttachmentFileFormat.PDF", "PDF"),
|
||||
CSV(3, "ReportMailingJobEmailAttachmentFileFormat.CSV", "CSV");
|
||||
|
||||
private String code;
|
||||
private String value;
|
||||
private Integer id;
|
||||
private final String code;
|
||||
private final String value;
|
||||
private final Integer id;
|
||||
|
||||
ReportMailingJobEmailAttachmentFileFormat(final Integer id, final String code, final String value) {
|
||||
this.value = value;
|
||||
|
||||
+3
-3
@@ -29,9 +29,9 @@ public enum ReportMailingJobStretchyReportParamDateOption {
|
||||
YESTERDAY(2, "ReportMailingJobStretchyReportParamDateOption.YESTERDAY", "Yesterday"),
|
||||
TOMORROW(3, "ReportMailingJobStretchyReportParamDateOption.TOMORROW", "Tomorrow");
|
||||
|
||||
private String code;
|
||||
private String value;
|
||||
private Integer id;
|
||||
private final String code;
|
||||
private final String value;
|
||||
private final Integer id;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
|
||||
+3
-3
@@ -24,9 +24,9 @@ public enum ReportMailingJobEmailAttachmentFileFormat {
|
||||
PDF(2, "ReportMailingJobEmailAttachmentFileFormat.pdf", "pdf"),
|
||||
CSV(3, "ReportMailingJobEmailAttachmentFileFormat.csv", "csv");
|
||||
|
||||
private String code;
|
||||
private String value;
|
||||
private Integer id;
|
||||
private final String code;
|
||||
private final String value;
|
||||
private final Integer id;
|
||||
|
||||
private ReportMailingJobEmailAttachmentFileFormat(final Integer id, final String code, final String value) {
|
||||
this.value = value;
|
||||
|
||||
+4
-4
@@ -27,9 +27,9 @@ public enum GroupTypes {
|
||||
CENTER(1L, "groupTypes.center", "center"), //
|
||||
GROUP(2L, "groupTypes.group", "group"); //
|
||||
|
||||
private Long id;
|
||||
private String code;
|
||||
private String value;
|
||||
private final Long id;
|
||||
private final String code;
|
||||
private final String value;
|
||||
|
||||
private GroupTypes(final Long id, final String code, final String value) {
|
||||
this.id = id;
|
||||
@@ -86,4 +86,4 @@ public enum GroupTypes {
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -38,9 +38,9 @@ public enum LendingStrategy {
|
||||
LINKED_LOAN(400, "lendingStrategy.linkedLoan", "linkedLoan"), //
|
||||
INVALID(900, "lendingStrategy.invalid", "invalid");
|
||||
|
||||
private Integer id;
|
||||
private String code;
|
||||
private String value;
|
||||
private final Integer id;
|
||||
private final String code;
|
||||
private final String value;
|
||||
|
||||
LendingStrategy(final Integer id, final String code, final String value) {
|
||||
this.id = id;
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@ public enum LoanPreClosureInterestCalculationStrategy {
|
||||
// REPAYMENT_PERIOD_DATE(3,
|
||||
// "loanPreClosureInterestCalculationStrategy.repaymentPeriodDate")
|
||||
|
||||
private Integer value;
|
||||
private String code;
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
private static final Map<Integer, LoanPreClosureInterestCalculationStrategy> intToEnumMap = new HashMap<>();
|
||||
private static int minValue;
|
||||
|
||||
+3
-3
@@ -31,9 +31,9 @@ public enum NoteType {
|
||||
SHARE_ACCOUNT(700, "noteType.shares", "accounts/share"),
|
||||
SAVINGS_TRANSACTION(800, "noteType.savings.transaction", "savingsTransactions");
|
||||
|
||||
private Integer value;
|
||||
private String code;
|
||||
private String apiUrl;
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
private final String apiUrl;
|
||||
|
||||
NoteType(final Integer value, final String code, final String apiUrl) {
|
||||
this.value = value;
|
||||
|
||||
+2
-9
@@ -28,8 +28,8 @@ public enum TemplateEntity {
|
||||
CLIENT(0, "client"), @SerializedName("loan")
|
||||
LOAN(1, "loan");
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private final int id;
|
||||
private final String name;
|
||||
|
||||
private TemplateEntity(final int id, final String name) {
|
||||
this.id = id;
|
||||
@@ -40,15 +40,8 @@ public enum TemplateEntity {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-9
@@ -31,8 +31,8 @@ public enum TemplateType {
|
||||
/**
|
||||
* @SerializedName("E-Mail") EMAIL(1, "E-Mail")
|
||||
*/
|
||||
private int id;
|
||||
private String name;
|
||||
private final int id;
|
||||
private final String name;
|
||||
|
||||
private TemplateType(final int id, final String name) {
|
||||
this.id = id;
|
||||
@@ -43,15 +43,8 @@ public enum TemplateType {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user