1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.sqlite.inspection.test
18 
19 data class Database(val name: String?, val tables: List<Table>) {
20     constructor(name: String?, vararg tables: Table) : this(name, tables.toList())
21 }
22 
23 data class Table(
24     val name: String,
25     val columns: List<Column>,
26     val isView: Boolean = false, // true for a view, false for a regular table
27     val viewQuery: String = "" // only relevant if isView = true
28 ) {
29     constructor(name: String, vararg columns: Column) : this(name, columns.toList())
30 }
31 
32 data class Column(
33     val name: String,
34     val type: String,
35     /**
36      * The value of [primaryKey] is either:
37      * - Zero for columns that are not part of the primary key.
38      * - The index of the column in the primary key for columns that are part of the primary key.
39      */
40     val primaryKey: Int = 0,
41     val isNotNull: Boolean = false,
42     val isUnique: Boolean = false
43 ) {
44     val isPrimaryKey: Boolean
45         get() = primaryKey > 0
46 }
47