forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostgresCompoundDataType.java
More file actions
45 lines (35 loc) · 1.2 KB
/
PostgresCompoundDataType.java
File metadata and controls
45 lines (35 loc) · 1.2 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
43
44
45
package sqlancer.postgres;
import java.util.Optional;
import sqlancer.postgres.PostgresSchema.PostgresDataType;
public final class PostgresCompoundDataType {
private final PostgresDataType dataType;
private final PostgresCompoundDataType elemType;
private final Integer size;
private PostgresCompoundDataType(PostgresDataType dataType, PostgresCompoundDataType elemType, Integer size) {
this.dataType = dataType;
this.elemType = elemType;
this.size = size;
}
public PostgresDataType getDataType() {
return dataType;
}
public PostgresCompoundDataType getElemType() {
if (elemType == null) {
throw new AssertionError();
}
return elemType;
}
public Optional<Integer> getSize() {
if (size == null) {
return Optional.empty();
} else {
return Optional.of(size);
}
}
public static PostgresCompoundDataType create(PostgresDataType type, int size) {
return new PostgresCompoundDataType(type, null, size);
}
public static PostgresCompoundDataType create(PostgresDataType type) {
return new PostgresCompoundDataType(type, null, null);
}
}