1 /* 2 * Copyright (C) 2017 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 /** 24 * Data class that holds the information about a foreign key reference, i.e. 25 * [androidx.room.ForeignKey]. 26 */ 27 @Serializable 28 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) 29 class ForeignKeyBundle( 30 @SerialName("table") val table: String, 31 @SerialName("onDelete") val onDelete: String, 32 @SerialName("onUpdate") val onUpdate: String, 33 @SerialName("columns") val columns: List<String>, 34 @SerialName("referencedColumns") val referencedColumns: List<String> 35 ) : SchemaEquality<ForeignKeyBundle> { 36 isSchemaEqualnull37 override fun isSchemaEqual(other: ForeignKeyBundle): Boolean { 38 if (table != other.table) return false 39 if (onDelete != other.onDelete) return false 40 if (onUpdate != other.onUpdate) return false 41 // order matters 42 return (columns == other.columns && referencedColumns == other.referencedColumns) 43 } 44 } 45