diff -r ed1d52c5aa94 -r 763d3961400b project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Weaponset.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Weaponset.java Sat Aug 18 00:22:33 2012 +0200 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Weaponset.java Sat Aug 18 00:47:51 2012 +0200 @@ -1,5 +1,7 @@ package org.hedgewars.hedgeroid.Datastructures; +import java.util.Comparator; + import org.hedgewars.hedgeroid.frontlib.Flib; public final class Weaponset { @@ -17,6 +19,65 @@ @Override public String toString() { - return name; // TODO use the generated one once StartGameActivity doesn't need this anymore + return "Weaponset [name=" + name + ", loadout=" + loadout + + ", crateProb=" + crateProb + ", crateAmmo=" + crateAmmo + + ", delay=" + delay + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((crateAmmo == null) ? 0 : crateAmmo.hashCode()); + result = prime * result + + ((crateProb == null) ? 0 : crateProb.hashCode()); + result = prime * result + ((delay == null) ? 0 : delay.hashCode()); + result = prime * result + ((loadout == null) ? 0 : loadout.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Weaponset other = (Weaponset) obj; + if (crateAmmo == null) { + if (other.crateAmmo != null) + return false; + } else if (!crateAmmo.equals(other.crateAmmo)) + return false; + if (crateProb == null) { + if (other.crateProb != null) + return false; + } else if (!crateProb.equals(other.crateProb)) + return false; + if (delay == null) { + if (other.delay != null) + return false; + } else if (!delay.equals(other.delay)) + return false; + if (loadout == null) { + if (other.loadout != null) + return false; + } else if (!loadout.equals(other.loadout)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + public static Comparator NAME_ORDER = new Comparator() { + public int compare(Weaponset lhs, Weaponset rhs) { + return String.CASE_INSENSITIVE_ORDER.compare(lhs.name, rhs.name); + } + }; }