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.PrimaryKey; 23 import android.support.annotation.NonNull; 24 import android.support.annotation.RestrictTo; 25 26 /** 27 * Stores system ids for a {@link WorkSpec} id. 28 * 29 * @hide 30 */ 31 @Entity(foreignKeys = { 32 @ForeignKey( 33 entity = WorkSpec.class, 34 parentColumns = "id", 35 childColumns = "work_spec_id", 36 onDelete = ForeignKey.CASCADE, 37 onUpdate = ForeignKey.CASCADE)}) 38 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) 39 public class SystemIdInfo { 40 @NonNull 41 @PrimaryKey 42 @ColumnInfo(name = "work_spec_id") 43 public final String workSpecId; 44 45 @ColumnInfo(name = "system_id") 46 public final int systemId; 47 48 public SystemIdInfo(@NonNull String workSpecId, int systemId) { 49 this.workSpecId = workSpecId; 50 this.systemId = systemId; 51 } 52 53 @Override 54 public boolean equals(Object o) { 55 if (this == o) return true; 56 if (o == null || getClass() != o.getClass()) return false; 57 58 SystemIdInfo that = (SystemIdInfo) o; 59 60 if (systemId != that.systemId) return false; 61 return workSpecId.equals(that.workSpecId); 62 } 63 64 @Override 65 public int hashCode() { 66 int result = workSpecId.hashCode(); 67 result = 31 * result + systemId; 68 return result; 69 } 70 } 71