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.Ignore; 21 22@SuppressWarnings("unused") 23public class AvgWeightByAge { 24 25 private int mAge; 26 27 @ColumnInfo(name = "AVG(mWeight)") 28 private float mWeight; 29 30 public AvgWeightByAge() { 31 } 32 33 @Ignore 34 public AvgWeightByAge(int age, float weight) { 35 mAge = age; 36 mWeight = weight; 37 } 38 39 public int getAge() { 40 return mAge; 41 } 42 43 public void setAge(int age) { 44 mAge = age; 45 } 46 47 public float getWeight() { 48 return mWeight; 49 } 50 51 public void setWeight(float weight) { 52 mWeight = weight; 53 } 54 55 @Override 56 public String toString() { 57 return "AvgWeightByAge{" 58 + "mAge=" + mAge 59 + ", mWeight=" + mWeight 60 + '}'; 61 } 62 63 @Override 64 public boolean equals(Object o) { 65 if (this == o) { 66 return true; 67 } 68 if (o == null || getClass() != o.getClass()) { 69 return false; 70 } 71 72 AvgWeightByAge that = (AvgWeightByAge) o; 73 74 //noinspection SimplifiableIfStatement 75 if (mAge != that.mAge) { 76 return false; 77 } 78 return Float.compare(that.mWeight, mWeight) == 0; 79 } 80 81 @Override 82 public int hashCode() { 83 int result = mAge; 84 result = 31 * result + (mWeight != +0.0f ? Float.floatToIntBits(mWeight) : 0); 85 return result; 86 } 87} 88