forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractTables.java
More file actions
42 lines (32 loc) · 1.11 KB
/
AbstractTables.java
File metadata and controls
42 lines (32 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package sqlancer.schema;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
public class AbstractTables<T extends AbstractTable<C, ?>, C extends AbstractTableColumn<?, ?>> {
private final List<T> tables;
private final List<C> columns;
public AbstractTables(List<T> tables) {
this.tables = tables;
columns = new ArrayList<>();
for (T t : tables) {
columns.addAll(t.getColumns());
}
}
public String tableNamesAsString() {
return tables.stream().map(t -> t.getName()).collect(Collectors.joining(", "));
}
public List<T> getTables() {
return tables;
}
public List<C> getColumns() {
return columns;
}
public String columnNamesAsString() {
return getColumns().stream().map(t -> t.getTable().getName() + "." + t.getName())
.collect(Collectors.joining(", "));
}
public String columnNamesAsString(Function<C, String> function) {
return getColumns().stream().map(function).collect(Collectors.joining(", "));
}
}