1 /*
2  * Copyright 2018 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.room.migration.bundle
18 
19 import androidx.annotation.RestrictTo
20 import kotlinx.serialization.SerialName
21 import kotlinx.serialization.Serializable
22 
23 /** Data class that holds the schema information about a [androidx.room.DatabaseView]. */
24 @Serializable
25 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
26 class DatabaseViewBundle(
27     @SerialName("viewName") val viewName: String,
28     @SerialName("createSql") val createSql: String
29 ) : SchemaEquality<DatabaseViewBundle> {
30 
31     /** CREATE VIEW SQL query that uses the actual view name. */
createViewnull32     fun createView(): String {
33         return replaceViewName(createSql, viewName)
34     }
35 
isSchemaEqualnull36     override fun isSchemaEqual(other: DatabaseViewBundle): Boolean {
37         return viewName == other.viewName && createSql == other.createSql
38     }
39 }
40