package org.argeo.slc.core.test.tree;\r
\r
+import java.io.Serializable;\r
import java.util.ArrayList;\r
import java.util.Date;\r
import java.util.List;\r
* structure.\r
*/\r
public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,\r
- Comparable<TreeTestResult>, AttachmentsEnabled {\r
+ Comparable<TreeTestResult>, AttachmentsEnabled, Serializable {\r
+ private static final long serialVersionUID = 1L;\r
+\r
private Log log = LogFactory.getLog(TreeTestResult.class);\r
\r
private List<TestResultListener<TreeTestResult>> listeners = new Vector<TestResultListener<TreeTestResult>>();\r
public int compareTo(TreeTestResult ttr2) {\r
TreeTestResult ttr1 = this;\r
if (ttr1.getCloseDate() != null && ttr2.getCloseDate() != null) {\r
- return -ttr1.getCloseDate().compareTo(ttr2.getCloseDate());\r
+ if (ttr1.getCloseDate().equals(ttr2.getCloseDate()))\r
+ return compareUuid(ttr1, ttr2);\r
+ else\r
+ return -ttr1.getCloseDate().compareTo(ttr2.getCloseDate());\r
} else if (ttr1.getCloseDate() != null && ttr2.getCloseDate() == null) {\r
return 1;\r
} else if (ttr1.getCloseDate() == null && ttr2.getCloseDate() != null) {\r
return -1;\r
} else {\r
+ return compareUuid(ttr1, ttr2);\r
+ }\r
+ }\r
+\r
+ protected int compareUuid(TestResult ttr1, TestResult ttr2) {\r
+ if (ttr1.getUuid() == null || ttr2.getUuid() == null)\r
+ throw new SlcException(\r
+ "Cannot compare tree test result with null uuid");\r
+ else {\r
+ if (ttr1.getUuid().equals(ttr2.getUuid()))\r
+ return 0;\r
return ttr1.getUuid().compareTo(ttr2.getUuid());\r
}\r
}\r
\r
+ public boolean equals(Object obj) {\r
+ if (obj instanceof TestResult)\r
+ return compareUuid(this, ((TestResult) obj)) == 0;\r
+ else\r
+ return false;\r
+ }\r
+\r
+ public int hashCode() {\r
+ if (uuid != null)\r
+ return uuid.hashCode();\r
+ else\r
+ return super.hashCode();\r
+ }\r
+\r
public Map<String, String> getAttributes() {\r
return attributes;\r
}\r