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 static android.arch.persistence.room.OnConflictStrategy.REPLACE; 20 21 import android.arch.persistence.room.Dao; 22 import android.arch.persistence.room.Insert; 23 import android.arch.persistence.room.Query; 24 import android.support.annotation.NonNull; 25 import android.support.annotation.Nullable; 26 27 /** 28 * A Data Access Object for {@link SystemIdInfo}. 29 */ 30 @Dao 31 public interface SystemIdInfoDao { 32 /** 33 * Inserts a {@link SystemIdInfo} into the database. 34 * 35 * @param systemIdInfo The {@link SystemIdInfo} to be inserted into the database. 36 */ 37 @Insert(onConflict = REPLACE) insertSystemIdInfo(@onNull SystemIdInfo systemIdInfo)38 void insertSystemIdInfo(@NonNull SystemIdInfo systemIdInfo); 39 40 /** 41 * @param workSpecId The {@link WorkSpec} identifier. 42 * @return The instance of {@link SystemIdInfo} if exists. 43 */ 44 @Nullable 45 @Query("SELECT * FROM SystemIdInfo WHERE work_spec_id=:workSpecId") getSystemIdInfo(@onNull String workSpecId)46 SystemIdInfo getSystemIdInfo(@NonNull String workSpecId); 47 48 /** 49 * Removes {@link SystemIdInfo} corresponding to the {@link WorkSpec} identifier. 50 * 51 * @param workSpecId The {@link WorkSpec} identifier. 52 */ 53 @Query("DELETE FROM SystemIdInfo where work_spec_id=:workSpecId") removeSystemIdInfo(@onNull String workSpecId)54 void removeSystemIdInfo(@NonNull String workSpecId); 55 } 56