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 17 package androidx.room.integration.testapp.vo; 18 19 import androidx.room.Entity; 20 import androidx.room.PrimaryKey; 21 22 /** 23 * The toys of a pet. 24 */ 25 @Entity 26 public class Toy { 27 @PrimaryKey(autoGenerate = true) 28 private int mId; 29 private String mName; 30 private int mPetId; 31 getId()32 public int getId() { 33 return mId; 34 } 35 setId(int id)36 public void setId(int id) { 37 mId = id; 38 } 39 getName()40 public String getName() { 41 return mName; 42 } 43 setName(String name)44 public void setName(String name) { 45 mName = name; 46 } 47 getPetId()48 public int getPetId() { 49 return mPetId; 50 } 51 setPetId(int petId)52 public void setPetId(int petId) { 53 mPetId = petId; 54 } 55 56 @Override equals(Object o)57 public boolean equals(Object o) { 58 if (this == o) return true; 59 if (o == null || getClass() != o.getClass()) return false; 60 61 Toy toy = (Toy) o; 62 63 if (mId != toy.mId) return false; 64 if (mPetId != toy.mPetId) return false; 65 return mName != null ? mName.equals(toy.mName) : toy.mName == null; 66 } 67 68 @Override hashCode()69 public int hashCode() { 70 int result = mId; 71 result = 31 * result + (mName != null ? mName.hashCode() : 0); 72 result = 31 * result + mPetId; 73 return result; 74 } 75 } 76