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.room.integration.testapp.database;
18 
19 import androidx.room.Entity;
20 import androidx.room.Ignore;
21 import androidx.room.PrimaryKey;
22 
23 /**
24  * Product.
25  */
26 @Entity
27 public class Product {
28 
29     @PrimaryKey
30     private int mId;
31 
32     private String mName;
33 
Product()34     public Product() {
35     }
36 
37     @Ignore
Product(int id, String name)38     public Product(int id, String name) {
39         mId = id;
40         mName = name;
41     }
42 
getId()43     public int getId() {
44         return mId;
45     }
46 
setId(int id)47     public void setId(int id) {
48         this.mId = id;
49     }
50 
getName()51     public String getName() {
52         return mName;
53     }
54 
setName(String name)55     public void setName(String name) {
56         this.mName = name;
57     }
58 
59     @Override
toString()60     public String toString() {
61         return "Product{mId=" + mId + ", mName='" + mName + "'}";
62     }
63 
64     @Override
equals(Object o)65     public boolean equals(Object o) {
66         if (this == o) return true;
67         if (!(o instanceof Product)) return false;
68         Product product = (Product) o;
69 
70         if (mId != product.mId) return false;
71         return mName != null ? mName.equals(product.mName) : product.mName == null;
72     }
73 
74     @Override
hashCode()75     public int hashCode() {
76         int result = mId;
77         result = 31 * result + (mName != null ? mName.hashCode() : 0);
78         return result;
79     }
80 }
81