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