1 18 19 package cowsultants.itracker.ejb.client.models; 20 21 import java.util.Comparator ; 22 23 public class IssueActivityModel extends GenericModel implements Comparator { 24 private int type; 25 private String description; 26 private boolean notificationSent; 27 private String userLogin; 28 private String firstName; 29 private String lastName; 30 private String email; 31 private Integer issueId; 32 private Integer userId; 33 34 public IssueActivityModel() { 35 } 36 37 public IssueActivityModel(int type, String description, Integer issueId, Integer userId) { 38 this.setType(type); 39 this.setDescription(description); 40 this.setIssueId(issueId); 41 this.setUserId(userId); 42 } 43 44 public IssueActivityModel(int type, String description, boolean notificationSent, Integer issueId, Integer userId) { 45 this(type, description, issueId, userId); 46 this.setNotificationSent(notificationSent); 47 } 48 49 public int getType() { 50 return type; 51 } 52 53 public void setType(int value) { 54 type = value; 55 } 56 57 public String getDescription() { 58 return description; 59 } 60 61 public void setDescription(String value) { 62 description = value; 63 } 64 65 public boolean getNotificationSent() { 66 return notificationSent; 67 } 68 69 public void setNotificationSent(boolean value) { 70 notificationSent = value; 71 } 72 73 public String getUserLogin() { 74 return userLogin; 75 } 76 77 public void setUserLogin(String value) { 78 userLogin = value; 79 } 80 81 public String getUserFirstName() { 82 return firstName; 83 } 84 85 public void setUserFirstName(String value) { 86 firstName = value; 87 } 88 89 public String getUserLastName() { 90 return lastName; 91 } 92 93 public void setUserLastName(String value) { 94 lastName = value; 95 } 96 97 public String getUserEmail() { 98 return email; 99 } 100 101 public void setUserEmail(String value) { 102 email = value; 103 } 104 105 public Integer getIssueId() { 106 return issueId; 107 } 108 109 public void setIssueId(Integer value) { 110 issueId = value; 111 } 112 113 public Integer getUserId() { 114 return userId; 115 } 116 117 public void setUserId(Integer value) { 118 userId = value; 119 } 120 121 public int compare(Object a, Object b) { 122 return this.new CompareByDate().compare(a, b); 123 } 124 125 public boolean equals(Object obj) { 126 return this.new CompareByDate().equals(obj); 127 } 128 129 public class CompareByDate implements Comparator { 130 protected boolean isAscending = true; 131 132 public CompareByDate() { 133 } 134 135 public CompareByDate(boolean isAscending) { 136 setAscending(isAscending); 137 } 138 139 public void setAscending(boolean value) { 140 this.isAscending = value; 141 } 142 143 public int compare(Object a, Object b) { 144 int result = 0; 145 146 if(! (a instanceof IssueActivityModel) || ! (b instanceof IssueActivityModel)) { 147 throw new ClassCastException (); 148 } 149 150 IssueActivityModel ma = (IssueActivityModel) a; 151 IssueActivityModel mb = (IssueActivityModel) b; 152 153 if(ma.getCreateDate() == null && mb.getCreateDate() == null) { 154 result = 0; 155 } else if(ma.getCreateDate() == null) { 156 result = 1; 157 } else if(mb.getCreateDate() == null) { 158 result = -1; 159 } else { 160 if(ma.getCreateDate().equals(mb.getCreateDate())) { 161 result = 0; 162 } else if(ma.getCreateDate().before(mb.getCreateDate())) { 163 result = -1; 164 } else { 165 result = 1; 166 } 167 } 168 169 return (isAscending ? result : result * -1); 170 } 171 172 public boolean equals(Object obj) { 173 if(! (obj instanceof IssueActivityModel)) { 174 return false; 175 } 176 177 try { 178 IssueActivityModel mo = (IssueActivityModel) obj; 179 if(IssueActivityModel.this.getCreateDate().equals(mo.getCreateDate()) && 180 IssueActivityModel.this.getUserLogin().equals(mo.getUserLogin()) && 181 IssueActivityModel.this.getDescription().equals(mo.getDescription())) { 182 return true; 183 } 184 } catch(ClassCastException cce) { 185 } 186 187 return false; 188 } 189 190 public int hashCode() { 191 return ((IssueActivityModel.this.getCreateDate() == null ? 1 : IssueActivityModel.this.getCreateDate().hashCode()) ^ 192 (IssueActivityModel.this.getUserLogin() == null ? 1 : IssueActivityModel.this.getUserLogin().hashCode()) ^ 193 (IssueActivityModel.this.getDescription() == null ? 1 : IssueActivityModel.this.getDescription().hashCode())); 194 } 195 } 196 } 197 | Popular Tags |