From 9b9e0dbfbcf7b72220c4dcc326f8c0c6a10458ec Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Thu, 29 Jun 2023 16:59:50 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EC=9D=B4=EB=A6=84=EC=97=86=EB=8A=94=20Col?= =?UTF-8?q?umnInfo=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/tool/codegen/table/ColumnInfo.java | 6 ++++++ .../java/cokr/xit/tool/codegen/table/TableInfo.java | 10 ++++++++++ .../cokr/xit/tool/codegen/table/TableInfoFactory.java | 5 +++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/cokr/xit/tool/codegen/table/ColumnInfo.java b/src/main/java/cokr/xit/tool/codegen/table/ColumnInfo.java index 836dc3d..749eaa5 100644 --- a/src/main/java/cokr/xit/tool/codegen/table/ColumnInfo.java +++ b/src/main/java/cokr/xit/tool/codegen/table/ColumnInfo.java @@ -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; diff --git a/src/main/java/cokr/xit/tool/codegen/table/TableInfo.java b/src/main/java/cokr/xit/tool/codegen/table/TableInfo.java index a3d1ddc..151f0b0 100644 --- a/src/main/java/cokr/xit/tool/codegen/table/TableInfo.java +++ b/src/main/java/cokr/xit/tool/codegen/table/TableInfo.java @@ -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 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); diff --git a/src/main/java/cokr/xit/tool/codegen/table/TableInfoFactory.java b/src/main/java/cokr/xit/tool/codegen/table/TableInfoFactory.java index 8e45e21..6416e37 100644 --- a/src/main/java/cokr/xit/tool/codegen/table/TableInfoFactory.java +++ b/src/main/java/cokr/xit/tool/codegen/table/TableInfoFactory.java @@ -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(); } } } \ No newline at end of file