FINERACT-2181: Refactor ResultColumnHeaderData using Lombok and modern Java new features
This commit is contained in:
committed by
Adam Saghy
parent
0b2e0c33a7
commit
8371e162ba
+14
-45
@@ -22,6 +22,7 @@ import jakarta.validation.constraints.NotNull;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
|
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||||
import org.apache.fineract.infrastructure.core.service.database.DatabaseType;
|
import org.apache.fineract.infrastructure.core.service.database.DatabaseType;
|
||||||
import org.apache.fineract.infrastructure.core.service.database.JdbcJavaType;
|
import org.apache.fineract.infrastructure.core.service.database.JdbcJavaType;
|
||||||
@@ -29,6 +30,7 @@ import org.apache.fineract.infrastructure.core.service.database.JdbcJavaType;
|
|||||||
/**
|
/**
|
||||||
* Immutable data object representing a resultset column.
|
* Immutable data object representing a resultset column.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public final class ResultsetColumnHeaderData implements Serializable {
|
public final class ResultsetColumnHeaderData implements Serializable {
|
||||||
|
|
||||||
private final String columnName;
|
private final String columnName;
|
||||||
@@ -39,7 +41,6 @@ public final class ResultsetColumnHeaderData implements Serializable {
|
|||||||
private final boolean isColumnPrimaryKey;
|
private final boolean isColumnPrimaryKey;
|
||||||
private final boolean isColumnUnique;
|
private final boolean isColumnUnique;
|
||||||
private final boolean isColumnIndexed;
|
private final boolean isColumnIndexed;
|
||||||
|
|
||||||
private final List<ResultsetColumnValueData> columnValues;
|
private final List<ResultsetColumnValueData> columnValues;
|
||||||
private final String columnCode;
|
private final String columnCode;
|
||||||
|
|
||||||
@@ -80,22 +81,10 @@ public final class ResultsetColumnHeaderData implements Serializable {
|
|||||||
this.columnDisplayType = calcDisplayType();
|
this.columnDisplayType = calcDisplayType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColumnName() {
|
|
||||||
return this.columnName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNamed(final String columnName) {
|
public boolean isNamed(final String columnName) {
|
||||||
return this.columnName.equalsIgnoreCase(columnName);
|
return this.columnName.equalsIgnoreCase(columnName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JdbcJavaType getColumnType() {
|
|
||||||
return this.columnType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getColumnLength() {
|
|
||||||
return this.columnLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getIsColumnNullable() {
|
public boolean getIsColumnNullable() {
|
||||||
return isColumnNullable;
|
return isColumnNullable;
|
||||||
}
|
}
|
||||||
@@ -112,18 +101,6 @@ public final class ResultsetColumnHeaderData implements Serializable {
|
|||||||
return isColumnIndexed;
|
return isColumnIndexed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisplayType getColumnDisplayType() {
|
|
||||||
return this.columnDisplayType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getColumnCode() {
|
|
||||||
return this.columnCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ResultsetColumnValueData> getColumnValues() {
|
|
||||||
return this.columnValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDateDisplayType() {
|
public boolean isDateDisplayType() {
|
||||||
return columnDisplayType == DisplayType.DATE;
|
return columnDisplayType == DisplayType.DATE;
|
||||||
}
|
}
|
||||||
@@ -195,27 +172,17 @@ public final class ResultsetColumnHeaderData implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- Calculation ---
|
// --- Calculation ---
|
||||||
|
|
||||||
private String adjustColumnType(String type) {
|
private String adjustColumnType(String type) {
|
||||||
type = type.toUpperCase();
|
type = type.toUpperCase();
|
||||||
switch (type) {
|
return switch (type) {
|
||||||
case "CLOB":
|
case "CLOB", "ENUM", "SET" -> "VARCHAR";
|
||||||
case "ENUM":
|
case "NEWDECIMAL" -> "DECIMAL";
|
||||||
case "SET":
|
case "LONGLONG" -> "BIGINT";
|
||||||
return "VARCHAR";
|
case "SHORT" -> "SMALLINT";
|
||||||
case "NEWDECIMAL":
|
case "TINY" -> "TINYINT";
|
||||||
return "DECIMAL";
|
case "INT24" -> "INT";
|
||||||
case "LONGLONG":
|
default -> type;
|
||||||
return "BIGINT";
|
};
|
||||||
case "SHORT":
|
|
||||||
return "SMALLINT";
|
|
||||||
case "TINY":
|
|
||||||
return "TINYINT";
|
|
||||||
case "INT24":
|
|
||||||
return "INT";
|
|
||||||
default:
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -272,7 +239,9 @@ public final class ResultsetColumnHeaderData implements Serializable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enum representing the different ways a column can be displayed.
|
||||||
public enum DisplayType {
|
public enum DisplayType {
|
||||||
TEXT, STRING, INTEGER, FLOAT, DECIMAL, DATE, TIME, DATETIME, BOOLEAN, BINARY, CODELOOKUP, CODEVALUE,;
|
TEXT, STRING, INTEGER, FLOAT, DECIMAL, DATE, TIME, DATETIME, BOOLEAN, BINARY, CODELOOKUP, CODEVALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user