Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FINERACT-2181: Refactor ResultsetColumnHeaderData using Lombok and modern java new features #4307

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
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.JdbcJavaType;

/**
* Immutable data object representing a resultset column.
*/
@Getter
public final class ResultsetColumnHeaderData implements Serializable {

private final String columnName;
Expand All @@ -39,7 +41,6 @@ public final class ResultsetColumnHeaderData implements Serializable {
private final boolean isColumnPrimaryKey;
private final boolean isColumnUnique;
private final boolean isColumnIndexed;

private final List<ResultsetColumnValueData> columnValues;
private final String columnCode;

Expand Down Expand Up @@ -80,22 +81,10 @@ private ResultsetColumnHeaderData(final String columnName, String columnType, fi
this.columnDisplayType = calcDisplayType();
}

public String getColumnName() {
return this.columnName;
}

public boolean isNamed(final String columnName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This methid is used in many classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a7med3del1973 could you please review the comment?

return this.columnName.equalsIgnoreCase(columnName);
}

public JdbcJavaType getColumnType() {
return this.columnType;
}

public Long getColumnLength() {
return this.columnLength;
}

public boolean getIsColumnNullable() {
return isColumnNullable;
}
Expand All @@ -112,18 +101,6 @@ public boolean getIsColumnIndexed() {
return isColumnIndexed;
}

public DisplayType getColumnDisplayType() {
return this.columnDisplayType;
}

public String getColumnCode() {
return this.columnCode;
}

public List<ResultsetColumnValueData> getColumnValues() {
return this.columnValues;
}

public boolean isDateDisplayType() {
return columnDisplayType == DisplayType.DATE;
}
Expand Down Expand Up @@ -195,27 +172,17 @@ public boolean hasPrecision(@NotNull DatabaseType dialect) {
}

// --- Calculation ---

private String adjustColumnType(String type) {
type = type.toUpperCase();
switch (type) {
case "CLOB":
case "ENUM":
case "SET":
return "VARCHAR";
case "NEWDECIMAL":
return "DECIMAL";
case "LONGLONG":
return "BIGINT";
case "SHORT":
return "SMALLINT";
case "TINY":
return "TINYINT";
case "INT24":
return "INT";
default:
return type;
}
return switch (type) {
case "CLOB", "ENUM", "SET" -> "VARCHAR";
case "NEWDECIMAL" -> "DECIMAL";
case "LONGLONG" -> "BIGINT";
case "SHORT" -> "SMALLINT";
case "TINY" -> "TINYINT";
case "INT24" -> "INT";
default -> type;
};
}

@NotNull
Expand Down Expand Up @@ -272,7 +239,9 @@ public static DisplayType calcColumnDisplayType(JdbcJavaType columnType) {
return null;
}

// Enum representing the different ways a column can be displayed.
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;
}

}
Loading