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 package androidx.work.impl.model 17 18 import androidx.annotation.RestrictTo 19 import androidx.room.ColumnInfo 20 import androidx.room.Entity 21 import androidx.room.ForeignKey 22 import androidx.room.Index 23 24 /** Database entity that defines a dependency between two [WorkSpec]s. */ 25 @Entity( 26 foreignKeys = 27 [ 28 ForeignKey( 29 entity = WorkSpec::class, 30 parentColumns = ["id"], 31 childColumns = ["work_spec_id"], 32 onDelete = ForeignKey.CASCADE, 33 onUpdate = ForeignKey.CASCADE 34 ), 35 ForeignKey( 36 entity = WorkSpec::class, 37 parentColumns = ["id"], 38 childColumns = ["prerequisite_id"], 39 onDelete = ForeignKey.CASCADE, 40 onUpdate = ForeignKey.CASCADE 41 ) 42 ], 43 primaryKeys = ["work_spec_id", "prerequisite_id"], 44 indices = [Index(value = ["work_spec_id"]), Index(value = ["prerequisite_id"])] 45 ) 46 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) 47 class Dependency( 48 @ColumnInfo(name = "work_spec_id") val workSpecId: String, 49 @ColumnInfo(name = "prerequisite_id") val prerequisiteId: String 50 ) 51