18 package org.turro.dossier.issue;
20 import java.util.Comparator;
21 import java.util.Date;
22 import org.turro.attach.entity.Attachment;
23 import org.turro.contacts.CommentIt;
24 import org.turro.contacts.StarIt;
25 import org.turro.contacts.VoteIt;
26 import org.turro.dossier.entity.IssueComment;
27 import org.turro.dossier.entity.IssuePredecessor;
28 import org.turro.util.CompareUtil;
37 public int compare(Object o1, Object o2) {
38 int result = CompareUtil.compare(getDate(o1), getDate(o2));
40 result = CompareUtil.compare(getDescription(o1), getDescription(o2));
43 result = CompareUtil.compare(getId(o1), getId(o2));
48 private long getId(Object obj) {
51 }
else if(obj instanceof IssuePredecessor) {
52 return ((IssuePredecessor) obj).getId();
53 }
else if(obj instanceof Attachment) {
54 return ((Attachment) obj).getId();
55 }
else if(obj instanceof CommentIt) {
56 return ((CommentIt) obj).getDateCreation().getTime();
57 }
else if(obj instanceof StarIt) {
58 return ((StarIt) obj).getDateCreation().getTime();
59 }
else if(obj instanceof VoteIt) {
60 return ((VoteIt) obj).getDateCreation().getTime();
65 private Date getDate(Object obj) {
66 if(obj instanceof IssueComment) {
67 return ((IssueComment) obj).getModification();
68 }
else if(obj instanceof IssuePredecessor) {
69 return ((IssuePredecessor) obj).getCreation();
70 }
else if(obj instanceof Attachment) {
71 return ((Attachment) obj).getModification();
72 }
else if(obj instanceof CommentIt) {
73 return ((CommentIt) obj).getDateCreation();
74 }
else if(obj instanceof StarIt) {
75 return ((StarIt) obj).getDateCreation();
76 }
else if(obj instanceof VoteIt) {
77 return ((VoteIt) obj).getDateCreation();
82 private String getDescription(Object obj) {
83 if(obj instanceof IssueComment) {
84 return ((IssueComment) obj).getComment();
85 }
else if(obj instanceof IssuePredecessor) {
86 return ((IssuePredecessor) obj).getFullDescription();
87 }
else if(obj instanceof Attachment) {
88 return ((Attachment) obj).getFileName();
89 }
else if(obj instanceof CommentIt) {
90 return ((CommentIt) obj).getId();
91 }
else if(obj instanceof StarIt) {
92 return ((StarIt) obj).getId();
93 }
else if(obj instanceof VoteIt) {
94 return ((VoteIt) obj).getId();
int compare(Object o1, Object o2)