15b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee/* 25b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * Copyright (C) 2015 The Android Open Source Project 35b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * 45b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * Licensed under the Apache License, Version 2.0 (the "License"); 55b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * you may not use this file except in compliance with the License. 65b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * You may obtain a copy of the License at 75b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * 85b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * http://www.apache.org/licenses/LICENSE-2.0 95b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * 105b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * Unless required by applicable law or agreed to in writing, software 115b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * distributed under the License is distributed on an "AS IS" BASIS, 125b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * See the License for the specific language governing permissions and 145b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * limitations under the License. 155b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee */ 165b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee 175b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Leepackage com.android.dialer.contactinfo; 185b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee 195b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Leeimport android.text.TextUtils; 205b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee 215b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee/** 225b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * Stores a phone number of a call with the country code where it originally occurred. This object 235b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * is used as a key in the {@code ContactInfoCache}. 245b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * 255b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * The country does not necessarily specify the country of the phone number itself, but rather 265b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee * it is the country in which the user was in when the call was placed or received. 275b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee */ 285b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Leepublic final class NumberWithCountryIso { 295b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee public final String number; 305b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee public final String countryIso; 315b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee 325b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee public NumberWithCountryIso(String number, String countryIso) { 335b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee this.number = number; 345b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee this.countryIso = countryIso; 355b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee } 365b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee 375b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee @Override 385b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee public boolean equals(Object o) { 395b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee if (o == null) return false; 405b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee if (!(o instanceof NumberWithCountryIso)) return false; 415b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee NumberWithCountryIso other = (NumberWithCountryIso) o; 425b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee return TextUtils.equals(number, other.number) 435b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee && TextUtils.equals(countryIso, other.countryIso); 445b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee } 455b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee 465b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee @Override 475b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee public int hashCode() { 485b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee int numberHashCode = number == null ? 0 : number.hashCode(); 495b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee int countryHashCode = countryIso == null ? 0 : countryIso.hashCode(); 505b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee 515b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee return numberHashCode ^ countryHashCode; 525b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee } 535b9ebe2cf5ddeabe0278399e9c547ce46a3f8a99Andrew Lee} 54