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.work.impl.model; 18 19 import android.arch.persistence.room.ColumnInfo; 20 import android.arch.persistence.room.Entity; 21 import android.arch.persistence.room.ForeignKey; 22 import android.arch.persistence.room.Index; 23 import android.support.annotation.NonNull; 24 import android.support.annotation.RestrictTo; 25 26 /** 27 * Database entity that defines a mapping from a name to a {@link WorkSpec} id. 28 * 29 * @hide 30 */ 31 32 @Entity(foreignKeys = { 33 @ForeignKey( 34 entity = WorkSpec.class, 35 parentColumns = "id", 36 childColumns = "work_spec_id", 37 onDelete = ForeignKey.CASCADE, 38 onUpdate = ForeignKey.CASCADE)}, 39 primaryKeys = {"name", "work_spec_id"}, 40 indices = {@Index(value = {"work_spec_id"})}) 41 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) 42 public class WorkName { 43 44 @NonNull 45 @ColumnInfo(name = "name") 46 public final String name; 47 48 @NonNull 49 @ColumnInfo(name = "work_spec_id") 50 public final String workSpecId; 51 52 public WorkName(@NonNull String name, @NonNull String workSpecId) { 53 this.name = name; 54 this.workSpecId = workSpecId; 55 } 56 } 57