PluginInfo implements Parcelable, Comparable<PluginInfo> { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((title == null) ? 0 : title.hashCode()); result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((componentName == null) ? 0 : componentName.hashCode()); return result; } PluginInfo(CharSequence title, CharSequence description, ComponentName componentName); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); @Override int compareTo(@NonNull PluginInfo another); final CharSequence title; final CharSequence description; final ComponentName componentName; transient Drawable icon; transient boolean isActive; public boolean hasPermission; static final Creator<PluginInfo> CREATOR; }
@Test public void ensurePluginInfoHashCodeWorks() { assertThat(pluginInfo1.hashCode()).isEqualTo(pluginInfo1_copy.hashCode()); assertThat(pluginInfo1.hashCode()).isNotEqualTo(pluginInfo2.hashCode()); }