-
Notifications
You must be signed in to change notification settings - Fork 14
/
UserRelatedTable.java
113 lines (101 loc) · 2.4 KB
/
UserRelatedTable.java
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package mil.nga.geopackage.extension.related;
import java.util.Collection;
import java.util.List;
import mil.nga.geopackage.GeoPackageException;
import mil.nga.geopackage.core.contents.Contents;
import mil.nga.geopackage.user.custom.UserCustomColumn;
import mil.nga.geopackage.user.custom.UserCustomTable;
/**
* User Defined Related Table
*
* @author osbornb
* @since 3.0.1
*/
public class UserRelatedTable extends UserCustomTable {
/**
* Relation name
*/
private final String relationName;
/**
* Foreign key to Contents
*/
private Contents contents;
/**
* Constructor
*
* @param tableName
* table name
* @param relationName
* relation name
* @param columns
* list of columns
*/
public UserRelatedTable(String tableName, String relationName,
List<UserCustomColumn> columns) {
this(tableName, relationName, columns, null);
}
/**
* Constructor
*
* @param tableName
* table name
* @param relationName
* relation name
* @param columns
* list of columns
* @param requiredColumns
* list of required columns
*/
public UserRelatedTable(String tableName, String relationName,
List<UserCustomColumn> columns, Collection<String> requiredColumns) {
super(tableName, columns, requiredColumns);
this.relationName = relationName;
}
/**
* Constructor
*
* @param relationName
* relation name
* @param userCustomTable
* user custom table
*/
public UserRelatedTable(String relationName, UserCustomTable userCustomTable) {
super(userCustomTable);
this.relationName = relationName;
}
/**
* Get the relation name
*
* @return relation name
*/
public String getRelationName() {
return relationName;
}
/**
* Get the contents
*
* @return contents
*/
public Contents getContents() {
return contents;
}
/**
* Set the contents
*
* @param contents
* contents
*/
public void setContents(Contents contents) {
this.contents = contents;
if (contents != null) {
// Verify the Contents have a relation name data type
String dataType = contents.getDataTypeString();
if (dataType == null || !dataType.equals(relationName)) {
throw new GeoPackageException("The "
+ Contents.class.getSimpleName() + " of a "
+ getClass().getSimpleName()
+ " must have a data type of " + relationName);
}
}
}
}