|
18 | 18 | import java.sql.JDBCType;
|
19 | 19 | import java.util.Objects;
|
20 | 20 | import java.util.Optional;
|
21 |
| -import java.util.function.Supplier; |
22 | 21 |
|
23 | 22 | import org.jetbrains.annotations.NotNull;
|
24 | 23 |
|
25 | 24 | public class SqlTable implements TableExpression {
|
26 | 25 |
|
27 |
| - protected Supplier<String> nameSupplier; |
| 26 | + protected String tableName; |
28 | 27 |
|
29 | 28 | protected SqlTable(String tableName) {
|
30 |
| - Objects.requireNonNull(tableName); |
31 |
| - |
32 |
| - this.nameSupplier = () -> tableName; |
33 |
| - } |
34 |
| - |
35 |
| - /** |
36 |
| - * Creates an SqlTable whose name can be changed at runtime. |
37 |
| - * |
38 |
| - * @param tableNameSupplier table name supplier |
39 |
| - * @deprecated please use {@link AliasableSqlTable} if you need to change the table name at runtime |
40 |
| - */ |
41 |
| - @Deprecated |
42 |
| - protected SqlTable(Supplier<String> tableNameSupplier) { |
43 |
| - Objects.requireNonNull(tableNameSupplier); |
44 |
| - |
45 |
| - this.nameSupplier = tableNameSupplier; |
46 |
| - } |
47 |
| - |
48 |
| - /** |
49 |
| - * Creates an SqlTable whose name can be changed at runtime. |
50 |
| - * |
51 |
| - * @param schemaSupplier schema supplier |
52 |
| - * @param tableName table name |
53 |
| - * @deprecated please use {@link AliasableSqlTable} if you need to change the table name at runtime |
54 |
| - */ |
55 |
| - @Deprecated |
56 |
| - protected SqlTable(Supplier<Optional<String>> schemaSupplier, String tableName) { |
57 |
| - this(Optional::empty, schemaSupplier, tableName); |
58 |
| - } |
59 |
| - |
60 |
| - /** |
61 |
| - * Creates an SqlTable whose name can be changed at runtime. |
62 |
| - * |
63 |
| - * @param catalogSupplier catalog supplier |
64 |
| - * @param schemaSupplier schema supplier |
65 |
| - * @param tableName table name |
66 |
| - * @deprecated please use {@link AliasableSqlTable} if you need to change the table name at runtime |
67 |
| - */ |
68 |
| - @Deprecated |
69 |
| - protected SqlTable(Supplier<Optional<String>> catalogSupplier, Supplier<Optional<String>> schemaSupplier, |
70 |
| - String tableName) { |
71 |
| - Objects.requireNonNull(catalogSupplier); |
72 |
| - Objects.requireNonNull(schemaSupplier); |
73 |
| - Objects.requireNonNull(tableName); |
74 |
| - |
75 |
| - this.nameSupplier = () -> compose(catalogSupplier, schemaSupplier, tableName); |
76 |
| - } |
77 |
| - |
78 |
| - private String compose(Supplier<Optional<String>> catalogSupplier, Supplier<Optional<String>> schemaSupplier, |
79 |
| - String tableName) { |
80 |
| - return catalogSupplier.get().map(c -> compose(c, schemaSupplier, tableName)) |
81 |
| - .orElseGet(() -> compose(schemaSupplier, tableName)); |
82 |
| - } |
83 |
| - |
84 |
| - private String compose(String catalog, Supplier<Optional<String>> schemaSupplier, String tableName) { |
85 |
| - return schemaSupplier.get().map(s -> composeCatalogSchemaAndTable(catalog, s, tableName)) |
86 |
| - .orElseGet(() -> composeCatalogAndTable(catalog, tableName)); |
87 |
| - } |
88 |
| - |
89 |
| - private String compose(Supplier<Optional<String>> schemaSupplier, String tableName) { |
90 |
| - return schemaSupplier.get().map(s -> composeSchemaAndTable(s, tableName)) |
91 |
| - .orElse(tableName); |
92 |
| - } |
93 |
| - |
94 |
| - private String composeCatalogAndTable(String catalog, String tableName) { |
95 |
| - return catalog + ".." + tableName; //$NON-NLS-1$ |
96 |
| - } |
97 |
| - |
98 |
| - private String composeSchemaAndTable(String schema, String tableName) { |
99 |
| - return schema + "." + tableName; //$NON-NLS-1$ |
100 |
| - } |
101 |
| - |
102 |
| - private String composeCatalogSchemaAndTable(String catalog, String schema, String tableName) { |
103 |
| - return catalog + "." + schema + "." + tableName; //$NON-NLS-1$ //$NON-NLS-2$ |
| 29 | + this.tableName = Objects.requireNonNull(tableName); |
104 | 30 | }
|
105 | 31 |
|
106 |
| - public String tableNameAtRuntime() { |
107 |
| - return nameSupplier.get(); |
| 32 | + public String tableName() { |
| 33 | + return tableName; |
108 | 34 | }
|
109 | 35 |
|
110 | 36 | public BasicColumn allColumns() {
|
|
0 commit comments