]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/exceptions/Problem.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / types / exceptions / Problem.java
1 package org.simantics.scl.compiler.types.exceptions;
2
3 public class Problem {
4     int start;
5     int end;
6     String description;
7
8     public Problem(int start, int end, String description) {
9         this.start = start;
10         this.end = end;
11         this.description = description;
12     }
13     
14     public int getStart() {
15         return start;
16     }
17     
18     public int getEnd() {
19         return end;
20     }
21     
22     public String getDescription() {
23         return description;
24     }    
25     
26     @Override
27     public String toString() {
28         StringBuilder b = new StringBuilder();
29         toString(b);
30         return b.toString();
31     }
32
33     void toString(StringBuilder b) {
34         b.append(start);
35         b.append("-");
36         b.append(end);
37         b.append(": ");
38         b.append(description);
39     }
40
41     @Override
42     public int hashCode() {
43         final int prime = 31;
44         int result = 1;
45         result = prime * result
46                 + ((description == null) ? 0 : description.hashCode());
47         result = prime * result + end;
48         result = prime * result + start;
49         return result;
50     }
51
52     @Override
53     public boolean equals(Object obj) {
54         if (this == obj)
55             return true;
56         if (obj == null)
57             return false;
58         if (getClass() != obj.getClass())
59             return false;
60         Problem other = (Problem) obj;
61         if (description == null) {
62             if (other.description != null)
63                 return false;
64         } else if (!description.equals(other.description))
65             return false;
66         if (end != other.end)
67             return false;
68         if (start != other.start)
69             return false;
70         return true;
71     }
72 }