Merge change 1470

* changes:
  Make android.content.ComponentName implement java.lang.Comparable.
This commit is contained in:
Android (Google) Code Review
2009-05-12 12:00:55 -07:00
2 changed files with 26 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ package android.content;
import android.os.Parcel;
import android.os.Parcelable;
import java.lang.Comparable;
/**
* Identifier for a specific application component
@@ -29,7 +30,7 @@ import android.os.Parcelable;
* name inside of that package.
*
*/
public final class ComponentName implements Parcelable {
public final class ComponentName implements Parcelable, Comparable<ComponentName> {
private final String mPackage;
private final String mClass;
@@ -196,6 +197,15 @@ public final class ComponentName implements Parcelable {
public int hashCode() {
return mPackage.hashCode() + mClass.hashCode();
}
public int compareTo(ComponentName that) {
int v;
v = this.mPackage.compareTo(that.mPackage);
if (v != 0) {
return v;
}
return this.mClass.compareTo(that.mClass);
}
public int describeContents() {
return 0;