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 package androidx.work 17 18 /** 19 * An enumeration of the conflict resolution policies available to unique [OneTimeWorkRequest]s in 20 * case of a collision. 21 */ 22 enum class ExistingWorkPolicy { 23 /** 24 * If there is existing pending (uncompleted) work with the same unique name, cancel and delete 25 * it. Then, insert the newly-specified work. 26 */ 27 REPLACE, 28 29 /** 30 * If there is existing pending (uncompleted) work with the same unique name, do nothing. 31 * Otherwise, insert the newly-specified work. 32 */ 33 KEEP, 34 35 /** 36 * If there is existing pending (uncompleted) work with the same unique name, append the 37 * newly-specified work as a child of all the leaves of that work sequence. Otherwise, insert 38 * the newly-specified work as the start of a new sequence. 39 * 40 * **Note:** When using APPEND with failed or cancelled prerequisites, newly enqueued work will 41 * also be marked as failed or cancelled respectively. Use 42 * [ExistingWorkPolicy.APPEND_OR_REPLACE] to create a new chain of work. 43 */ 44 APPEND, 45 46 /** 47 * If there is existing pending (uncompleted) work with the same unique name, append the 48 * newly-specified work as the child of all the leaves of that work sequence. Otherwise, insert 49 * the newly-specified work as the start of a new sequence. 50 * 51 * **Note:** If there are failed or cancelled prerequisites, these prerequisites are *dropped* 52 * and the newly-specified work is the start of a new sequence. 53 */ 54 APPEND_OR_REPLACE 55 } 56