Added hashcode function for Team to make it consistent with equals.
authorMedo <smaxein@googlemail.com>
Sat, 31 Mar 2012 20:36:03 +0200
changeset 6840 c61f842621b8
parent 6839 2dd2c0f2c9d0
child 6842 2e6391f33204
Added hashcode function for Team to make it consistent with equals.
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java	Fri Mar 30 19:40:49 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java	Sat Mar 31 20:36:03 2012 +0200
@@ -88,6 +88,7 @@
 		readFromParcel(in);
 	}
 
+	@Override
 	public boolean equals(Object o){
 		if(super.equals(o)) return true;
 		else if(o instanceof Team){
@@ -103,6 +104,19 @@
 			return false;
 		}
 	}
+	
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((name == null) ? 0 : name.hashCode());
+		result = prime * result + ((grave == null) ? 0 : grave.hashCode());
+		result = prime * result + ((flag == null) ? 0 : flag.hashCode());
+		result = prime * result + ((voice == null) ? 0 : voice.hashCode());
+		result = prime * result + ((fort == null) ? 0 : fort.hashCode());
+		result = prime * result + ((hash == null) ? 0 : hash.hashCode());
+		return result;
+	}
 
 	public void setRandomColor(int[] illegalcolors){
 		Integer[] colorsToPickFrom = TEAM_COLORS;