public class Country extends Object implements Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static int |
COUNTRY_SOURCE_LOCALE
The country code came from the system locale setting
|
static int |
COUNTRY_SOURCE_LOCATION
The country code came from the location service
|
static int |
COUNTRY_SOURCE_NETWORK
The country code came from the mobile network
|
static int |
COUNTRY_SOURCE_SIM
The country code was read from the SIM card
|
static Parcelable.Creator<Country> |
CREATOR |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
Country(Country country) |
Country(String countryIso,
int source) |
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
boolean |
equals(Object object)
Returns true if this
Country is equivalent to the given object. |
boolean |
equalsIgnoreSource(Country country)
Compare the specified country to this country object ignoring the source
and timestamp fields, return true if the countryIso fields are equal
|
String |
getCountryIso() |
int |
getSource() |
long |
getTimestamp()
Returns the time that this object was created (which we assume to be the time that the source
was consulted).
|
int |
hashCode()
Returns a hash code value for the object.
|
String |
toString()
Returns a string representation of the object.
|
void |
writeToParcel(Parcel parcel,
int flags)
Flatten this object in to a Parcel.
|
public static final int COUNTRY_SOURCE_NETWORK
public static final int COUNTRY_SOURCE_LOCATION
public static final int COUNTRY_SOURCE_SIM
public static final int COUNTRY_SOURCE_LOCALE
public static final Parcelable.Creator<Country> CREATOR
public Country(String countryIso, int source)
countryIso
- the ISO 3166-1 two letters country code.source
- where the countryIso came from, could be one of below
values
public Country(Country country)
public final String getCountryIso()
public final int getSource()
public final long getTimestamp()
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel parcel, int flags)
Parcelable
writeToParcel
in interface Parcelable
parcel
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public boolean equals(Object object)
Country
is equivalent to the given object. This ignores
the timestamp value and just checks for equivalence of countryIso and source values.
Returns false otherwise.equals
in class Object
object
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public boolean equalsIgnoreSource(Country country)
country
- the country to comparepublic String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())