]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.issues.common/src/org/simantics/issues/common/SimpleIssue.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.issues.common / src / org / simantics / issues / common / SimpleIssue.java
1 package org.simantics.issues.common;\r
2 \r
3 import org.simantics.db.Resource;\r
4 import org.simantics.issues.Severity;\r
5 \r
6 \r
7 public class SimpleIssue {\r
8     public static final SimpleIssue[] EMPTY_ARRAY = new SimpleIssue[0];\r
9     \r
10     public final String label;\r
11     public final Severity severity;\r
12     // Optional, not used for equals/hashCode\r
13     public final Resource issueResource;\r
14     \r
15     public SimpleIssue(String label, Severity severity) {\r
16         this(label, severity, null);\r
17     }\r
18     \r
19     public SimpleIssue(String label, Severity severity, Resource issueResource) {\r
20         if(label == null)\r
21             throw new NullPointerException();\r
22         if(severity == null)\r
23             throw new NullPointerException();\r
24         this.label = label;\r
25         this.severity = severity;\r
26         this.issueResource = issueResource;\r
27     }\r
28 \r
29     @Override\r
30     public int hashCode() {\r
31         return 31*label.hashCode() + severity.hashCode();\r
32     }\r
33 \r
34     @Override\r
35     public boolean equals(Object obj) {\r
36         if (this == obj)\r
37             return true;\r
38         if (obj == null)\r
39             return false;\r
40         if (getClass() != obj.getClass())\r
41             return false;\r
42         SimpleIssue other = (SimpleIssue) obj;\r
43         return severity.equals(other.severity) && label.equals(other.label);                \r
44     }\r
45 }\r