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",
|
"VarTypeName",
|
||||||
"ArgumentSelectionDefectChecker",
|
"ArgumentSelectionDefectChecker",
|
||||||
"CompareToZero",
|
"CompareToZero",
|
||||||
|
"ImmutableEnumChecker",
|
||||||
"NarrowingCompoundAssignment",
|
"NarrowingCompoundAssignment",
|
||||||
"MissingCasesInEnumSwitch",
|
"MissingCasesInEnumSwitch",
|
||||||
"ReferenceEquality",
|
"ReferenceEquality",
|
||||||
@@ -443,7 +444,8 @@ modernizer {
|
|||||||
|
|
||||||
ignorePackages = []
|
ignorePackages = []
|
||||||
ignoreClassNamePatterns = [
|
ignoreClassNamePatterns = [
|
||||||
'.*AbstractPersistableCustom'
|
'.*AbstractPersistableCustom',
|
||||||
|
'.*EntityTables'
|
||||||
]
|
]
|
||||||
ignoreGeneratedClasses = true
|
ignoreGeneratedClasses = true
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -23,8 +23,8 @@ import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
|||||||
public enum CampaignType {
|
public enum CampaignType {
|
||||||
INVALID(0, "campaignType.invalid"), SMS(1, "campaignType.sms"), NOTIFICATION(2, "campaignType.notification");
|
INVALID(0, "campaignType.invalid"), SMS(1, "campaignType.sms"), NOTIFICATION(2, "campaignType.notification");
|
||||||
|
|
||||||
private Integer value;
|
private final Integer value;
|
||||||
private String code;
|
private final String code;
|
||||||
|
|
||||||
private CampaignType(Integer value, String code) {
|
private CampaignType(Integer value, String code) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|||||||
+2
-2
@@ -22,8 +22,8 @@ public enum EmailCampaignType {
|
|||||||
DIRECT(1,"emailCampaignStatusType.direct"),
|
DIRECT(1,"emailCampaignStatusType.direct"),
|
||||||
SCHEDULE(2,"emailCampaignStatusType.schedule");
|
SCHEDULE(2,"emailCampaignStatusType.schedule");
|
||||||
|
|
||||||
private Integer value;
|
private final Integer value;
|
||||||
private String code;
|
private final String code;
|
||||||
|
|
||||||
EmailCampaignType(Integer value, String code) {
|
EmailCampaignType(Integer value, String code) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|||||||
+3
-3
@@ -24,9 +24,9 @@ public enum ScheduledEmailAttachmentFileFormat {
|
|||||||
PDF(2, "EmailAttachmentFileFormat.pdf", "pdf"),
|
PDF(2, "EmailAttachmentFileFormat.pdf", "pdf"),
|
||||||
CSV(3, "EmailAttachmentFileFormat.csv", "csv");
|
CSV(3, "EmailAttachmentFileFormat.csv", "csv");
|
||||||
|
|
||||||
private String code;
|
private final String code;
|
||||||
private String value;
|
private final String value;
|
||||||
private Integer id;
|
private final Integer id;
|
||||||
|
|
||||||
ScheduledEmailAttachmentFileFormat(final Integer id, final String code, final String value) {
|
ScheduledEmailAttachmentFileFormat(final Integer id, final String code, final String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|||||||
+3
-3
@@ -24,9 +24,9 @@ public enum ScheduledEmailStretchyReportParamDateOption {
|
|||||||
// YESTERDAY(2, "scheduledEmailStretchyReportParamDateOption.yesterday", "yesterday"),
|
// YESTERDAY(2, "scheduledEmailStretchyReportParamDateOption.yesterday", "yesterday"),
|
||||||
TOMORROW(3, "scheduledEmailStretchyReportParamDateOption.tomorrow", "tomorrow");
|
TOMORROW(3, "scheduledEmailStretchyReportParamDateOption.tomorrow", "tomorrow");
|
||||||
|
|
||||||
private String code;
|
private final String code;
|
||||||
private String value;
|
private final String value;
|
||||||
private Integer id;
|
private final Integer id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param 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,
|
INVALID(-1, "triggerType.invalid"), DIRECT(1, "triggerType.direct"), SCHEDULE(2, "triggerType.schedule"), TRIGGERED(3,
|
||||||
"triggerType.triggered");
|
"triggerType.triggered");
|
||||||
|
|
||||||
private Integer value;
|
private final Integer value;
|
||||||
private String code;
|
private final String code;
|
||||||
|
|
||||||
private SmsCampaignTriggerType(Integer value, String code) {
|
private SmsCampaignTriggerType(Integer value, String code) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|||||||
+31
-30
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.infrastructure.dataqueries.data;
|
package org.apache.fineract.infrastructure.dataqueries.data;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -26,45 +27,45 @@ import java.util.Map;
|
|||||||
public enum EntityTables {
|
public enum EntityTables {
|
||||||
|
|
||||||
CLIENT("m_client",
|
CLIENT("m_client",
|
||||||
new Integer[]{StatusEnum.CREATE.getCode(),
|
ImmutableList.of(StatusEnum.CREATE.getCode(),
|
||||||
StatusEnum.ACTIVATE.getCode(),
|
StatusEnum.ACTIVATE.getCode(),
|
||||||
StatusEnum.CLOSE.getCode()},
|
StatusEnum.CLOSE.getCode()),
|
||||||
"client_id"),
|
"client_id"),
|
||||||
LOAN("m_loan",
|
LOAN("m_loan",
|
||||||
new Integer[]{StatusEnum.CREATE.getCode(),
|
ImmutableList.of(StatusEnum.CREATE.getCode(),
|
||||||
StatusEnum.APPROVE.getCode(),
|
StatusEnum.APPROVE.getCode(),
|
||||||
StatusEnum.DISBURSE.getCode(),
|
StatusEnum.DISBURSE.getCode(),
|
||||||
StatusEnum.WITHDRAWN.getCode(),
|
StatusEnum.WITHDRAWN.getCode(),
|
||||||
StatusEnum.REJECTED.getCode(),
|
StatusEnum.REJECTED.getCode(),
|
||||||
StatusEnum.WRITE_OFF.getCode()},
|
StatusEnum.WRITE_OFF.getCode()),
|
||||||
"loan_id"),
|
"loan_id"),
|
||||||
GROUP("m_group",
|
GROUP("m_group",
|
||||||
new Integer[]{StatusEnum.CREATE.getCode(),
|
ImmutableList.of(StatusEnum.CREATE.getCode(),
|
||||||
StatusEnum.ACTIVATE.getCode(),
|
StatusEnum.ACTIVATE.getCode(),
|
||||||
StatusEnum.CLOSE.getCode(),},
|
StatusEnum.CLOSE.getCode()),
|
||||||
"group_id"),
|
"group_id"),
|
||||||
SAVING("m_savings_account",
|
SAVING("m_savings_account",
|
||||||
new Integer[]{StatusEnum.CREATE.getCode(),
|
ImmutableList.of(StatusEnum.CREATE.getCode(),
|
||||||
StatusEnum.APPROVE.getCode(),
|
StatusEnum.APPROVE.getCode(),
|
||||||
StatusEnum.ACTIVATE.getCode(),
|
StatusEnum.ACTIVATE.getCode(),
|
||||||
StatusEnum.WITHDRAWN.getCode(),
|
StatusEnum.WITHDRAWN.getCode(),
|
||||||
StatusEnum.REJECTED.getCode(),
|
StatusEnum.REJECTED.getCode(),
|
||||||
StatusEnum.CLOSE.getCode()},
|
StatusEnum.CLOSE.getCode()),
|
||||||
"savings_account_id");
|
"savings_account_id");
|
||||||
|
|
||||||
private static final Map<String, EntityTables> lookup = new HashMap<String, EntityTables>();
|
private static final Map<String, EntityTables> lookup = new HashMap<String, EntityTables>();
|
||||||
static {
|
static {
|
||||||
for (EntityTables d : EntityTables.values())
|
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.name = name;
|
||||||
this.codes = codes;
|
this.codes = codes;
|
||||||
this.foreignKeyColumnNameOnDatatable = foreignKeyColumnNameOnDatatable;
|
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) {
|
if (lookup.get(name) != null) {
|
||||||
return lookup.get(name).getCodes();
|
return lookup.get(name).getCodes();
|
||||||
}
|
}
|
||||||
return new Integer[]{};
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer[] getCodes() {
|
public ImmutableList<Integer> getCodes() {
|
||||||
return this.codes;
|
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(
|
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);
|
"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;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer code;
|
|
||||||
|
|
||||||
private StatusEnum(String name, Integer code) {
|
private StatusEnum(String name, Integer code) {
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ public final class EntityDatatableChecksDataValidator {
|
|||||||
.isOneOfTheseStringValues(EntityTables.getEntitiesList());
|
.isOneOfTheseStringValues(EntityTables.getEntitiesList());
|
||||||
|
|
||||||
final Integer status = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("status", element);
|
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);
|
baseDataValidator.reset().parameter("status").value(status).isOneOfTheseValues(entityTablesStatuses);
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.infrastructure.dataqueries.service;
|
package org.apache.fineract.infrastructure.dataqueries.service;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
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<>();
|
List<DatatableCheckStatusData> ret = new ArrayList<>();
|
||||||
if (statuses != null) {
|
if (statuses != null) {
|
||||||
for (Integer status : statuses) {
|
for (Integer status : statuses) {
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ import java.util.Map;
|
|||||||
public enum StorageType {
|
public enum StorageType {
|
||||||
FILE_SYSTEM(1), S3(2);
|
FILE_SYSTEM(1), S3(2);
|
||||||
|
|
||||||
private Integer value;
|
private final Integer value;
|
||||||
|
|
||||||
StorageType(final Integer value) {
|
StorageType(final Integer value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|||||||
+3
-3
@@ -29,9 +29,9 @@ public enum ReportMailingJobEmailAttachmentFileFormat {
|
|||||||
PDF(2, "ReportMailingJobEmailAttachmentFileFormat.PDF", "PDF"),
|
PDF(2, "ReportMailingJobEmailAttachmentFileFormat.PDF", "PDF"),
|
||||||
CSV(3, "ReportMailingJobEmailAttachmentFileFormat.CSV", "CSV");
|
CSV(3, "ReportMailingJobEmailAttachmentFileFormat.CSV", "CSV");
|
||||||
|
|
||||||
private String code;
|
private final String code;
|
||||||
private String value;
|
private final String value;
|
||||||
private Integer id;
|
private final Integer id;
|
||||||
|
|
||||||
ReportMailingJobEmailAttachmentFileFormat(final Integer id, final String code, final String value) {
|
ReportMailingJobEmailAttachmentFileFormat(final Integer id, final String code, final String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|||||||
+3
-3
@@ -29,9 +29,9 @@ public enum ReportMailingJobStretchyReportParamDateOption {
|
|||||||
YESTERDAY(2, "ReportMailingJobStretchyReportParamDateOption.YESTERDAY", "Yesterday"),
|
YESTERDAY(2, "ReportMailingJobStretchyReportParamDateOption.YESTERDAY", "Yesterday"),
|
||||||
TOMORROW(3, "ReportMailingJobStretchyReportParamDateOption.TOMORROW", "Tomorrow");
|
TOMORROW(3, "ReportMailingJobStretchyReportParamDateOption.TOMORROW", "Tomorrow");
|
||||||
|
|
||||||
private String code;
|
private final String code;
|
||||||
private String value;
|
private final String value;
|
||||||
private Integer id;
|
private final Integer id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id
|
* @param id
|
||||||
|
|||||||
+3
-3
@@ -24,9 +24,9 @@ public enum ReportMailingJobEmailAttachmentFileFormat {
|
|||||||
PDF(2, "ReportMailingJobEmailAttachmentFileFormat.pdf", "pdf"),
|
PDF(2, "ReportMailingJobEmailAttachmentFileFormat.pdf", "pdf"),
|
||||||
CSV(3, "ReportMailingJobEmailAttachmentFileFormat.csv", "csv");
|
CSV(3, "ReportMailingJobEmailAttachmentFileFormat.csv", "csv");
|
||||||
|
|
||||||
private String code;
|
private final String code;
|
||||||
private String value;
|
private final String value;
|
||||||
private Integer id;
|
private final Integer id;
|
||||||
|
|
||||||
private ReportMailingJobEmailAttachmentFileFormat(final Integer id, final String code, final String value) {
|
private ReportMailingJobEmailAttachmentFileFormat(final Integer id, final String code, final String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|||||||
+3
-3
@@ -27,9 +27,9 @@ public enum GroupTypes {
|
|||||||
CENTER(1L, "groupTypes.center", "center"), //
|
CENTER(1L, "groupTypes.center", "center"), //
|
||||||
GROUP(2L, "groupTypes.group", "group"); //
|
GROUP(2L, "groupTypes.group", "group"); //
|
||||||
|
|
||||||
private Long id;
|
private final Long id;
|
||||||
private String code;
|
private final String code;
|
||||||
private String value;
|
private final String value;
|
||||||
|
|
||||||
private GroupTypes(final Long id, final String code, final String value) {
|
private GroupTypes(final Long id, final String code, final String value) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|||||||
+3
-3
@@ -38,9 +38,9 @@ public enum LendingStrategy {
|
|||||||
LINKED_LOAN(400, "lendingStrategy.linkedLoan", "linkedLoan"), //
|
LINKED_LOAN(400, "lendingStrategy.linkedLoan", "linkedLoan"), //
|
||||||
INVALID(900, "lendingStrategy.invalid", "invalid");
|
INVALID(900, "lendingStrategy.invalid", "invalid");
|
||||||
|
|
||||||
private Integer id;
|
private final Integer id;
|
||||||
private String code;
|
private final String code;
|
||||||
private String value;
|
private final String value;
|
||||||
|
|
||||||
LendingStrategy(final Integer id, final String code, final String value) {
|
LendingStrategy(final Integer id, final String code, final String value) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|||||||
+2
-2
@@ -30,8 +30,8 @@ public enum LoanPreClosureInterestCalculationStrategy {
|
|||||||
// REPAYMENT_PERIOD_DATE(3,
|
// REPAYMENT_PERIOD_DATE(3,
|
||||||
// "loanPreClosureInterestCalculationStrategy.repaymentPeriodDate")
|
// "loanPreClosureInterestCalculationStrategy.repaymentPeriodDate")
|
||||||
|
|
||||||
private Integer value;
|
private final Integer value;
|
||||||
private String code;
|
private final String code;
|
||||||
|
|
||||||
private static final Map<Integer, LoanPreClosureInterestCalculationStrategy> intToEnumMap = new HashMap<>();
|
private static final Map<Integer, LoanPreClosureInterestCalculationStrategy> intToEnumMap = new HashMap<>();
|
||||||
private static int minValue;
|
private static int minValue;
|
||||||
|
|||||||
+3
-3
@@ -31,9 +31,9 @@ public enum NoteType {
|
|||||||
SHARE_ACCOUNT(700, "noteType.shares", "accounts/share"),
|
SHARE_ACCOUNT(700, "noteType.shares", "accounts/share"),
|
||||||
SAVINGS_TRANSACTION(800, "noteType.savings.transaction", "savingsTransactions");
|
SAVINGS_TRANSACTION(800, "noteType.savings.transaction", "savingsTransactions");
|
||||||
|
|
||||||
private Integer value;
|
private final Integer value;
|
||||||
private String code;
|
private final String code;
|
||||||
private String apiUrl;
|
private final String apiUrl;
|
||||||
|
|
||||||
NoteType(final Integer value, final String code, final String apiUrl) {
|
NoteType(final Integer value, final String code, final String apiUrl) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|||||||
+2
-9
@@ -28,8 +28,8 @@ public enum TemplateEntity {
|
|||||||
CLIENT(0, "client"), @SerializedName("loan")
|
CLIENT(0, "client"), @SerializedName("loan")
|
||||||
LOAN(1, "loan");
|
LOAN(1, "loan");
|
||||||
|
|
||||||
private int id;
|
private final int id;
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
private TemplateEntity(final int id, final String name) {
|
private TemplateEntity(final int id, final String name) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -40,15 +40,8 @@ public enum TemplateEntity {
|
|||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(final String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return this.id;
|
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")
|
* @SerializedName("E-Mail") EMAIL(1, "E-Mail")
|
||||||
*/
|
*/
|
||||||
private int id;
|
private final int id;
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
private TemplateType(final int id, final String name) {
|
private TemplateType(final int id, final String name) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -43,15 +43,8 @@ public enum TemplateType {
|
|||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(final int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(final String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user