1 /* 2 * Copyright (C) 2015 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 com.android.dialer.app.contactinfo; 18 19 import android.text.TextUtils; 20 21 /** 22 * Stores a phone number of a call with the country code where it originally occurred. This object 23 * is used as a key in the {@code ContactInfoCache}. 24 * 25 * <p>The country does not necessarily specify the country of the phone number itself, but rather it 26 * is the country in which the user was in when the call was placed or received. 27 */ 28 public final class NumberWithCountryIso { 29 30 public final String number; 31 public final String countryIso; 32 NumberWithCountryIso(String number, String countryIso)33 public NumberWithCountryIso(String number, String countryIso) { 34 this.number = number; 35 this.countryIso = countryIso; 36 } 37 38 @Override equals(Object o)39 public boolean equals(Object o) { 40 if (o == null) { 41 return false; 42 } 43 if (!(o instanceof NumberWithCountryIso)) { 44 return false; 45 } 46 NumberWithCountryIso other = (NumberWithCountryIso) o; 47 return TextUtils.equals(number, other.number) && TextUtils.equals(countryIso, other.countryIso); 48 } 49 50 @Override hashCode()51 public int hashCode() { 52 int numberHashCode = number == null ? 0 : number.hashCode(); 53 int countryHashCode = countryIso == null ? 0 : countryIso.hashCode(); 54 55 return numberHashCode ^ countryHashCode; 56 } 57 } 58