데이터 클래스 이름없는 ColumnInfo 수정

master
mjkhan21 1 year ago
parent 14178d7a8a
commit 9b9e0dbfbc

@ -1,5 +1,7 @@
package cokr.xit.tool.codegen.table;
import cokr.xit.foundation.Assert;
/**
* @author mjkhan
*/
@ -53,6 +55,10 @@ public class ColumnInfo {
return className;
}
public boolean hasClassName() {
return !Assert.isEmpty(className);
}
public ColumnInfo setClassName(String className) {
this.className = className;
return this;

@ -1,6 +1,7 @@
package cokr.xit.tool.codegen.table;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
@ -39,6 +40,15 @@ public class TableInfo {
return this;
}
public TableInfo removeClassNotFound() {
List<String> notFounds = columns.entrySet().stream()
.filter(entry -> !entry.getValue().hasClassName())
.map(entry -> entry.getKey())
.toList();
notFounds.forEach(key -> columns.remove(key));
return this;
}
@Override
public String toString() {
return String.format("Table(%s, %s)", name, comment);

@ -36,7 +36,8 @@ public class TableInfoFactory {
private TableInfo getTable(String tableName, DatabaseMetaData metadata) throws Exception {
try (ResultSet resultSet = metadata.getTables(null, null, tableName, null);) {
while (resultSet.next()) {
TableInfo table = new TableInfo().setName(tableName);
TableInfo table = new TableInfo()
.setName(tableName);
table.setComment(resultSet.getString("REMARKS"));
return table;
}
@ -94,7 +95,7 @@ public class TableInfoFactory {
String className = metadata.getColumnClassName(i);
table.getColumns().get(columnName).setClassName(className);
}
table.removeClassNotFound();
}
}
}
Loading…
Cancel
Save