comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java @ 9822:e210293dca77

Generated hashCode and equals for SourceSection. Source is abstract, so just uses identity methods for that.
author Chris Seaton <chris.seaton@oracle.com>
date Sat, 25 May 2013 16:31:05 -0700
parents 5dc05fdcf3c2
children b9b8af46c2b7
comparison
equal deleted inserted replaced
9821:32d8115dade8 9822:e210293dca77
121 @Override 121 @Override
122 public String toString() { 122 public String toString() {
123 return String.format("%s:%d", source.getName(), startLine); 123 return String.format("%s:%d", source.getName(), startLine);
124 } 124 }
125 125
126 @Override
127 public int hashCode() {
128 final int prime = 31;
129 int result = 1;
130 result = prime * result + charIndex;
131 result = prime * result + charLength;
132 result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
133 result = prime * result + ((source == null) ? 0 : source.hashCode());
134 result = prime * result + startColumn;
135 result = prime * result + startLine;
136 return result;
137 }
138
139 @Override
140 public boolean equals(Object obj) {
141 if (this == obj) {
142 return true;
143 }
144 if (obj == null) {
145 return false;
146 }
147 if (!(obj instanceof SourceSection)) {
148 return false;
149 }
150 SourceSection other = (SourceSection) obj;
151 if (charIndex != other.charIndex) {
152 return false;
153 }
154 if (charLength != other.charLength) {
155 return false;
156 }
157 if (identifier == null) {
158 if (other.identifier != null) {
159 return false;
160 }
161 } else if (!identifier.equals(other.identifier)) {
162 return false;
163 }
164 if (source == null) {
165 if (other.source != null) {
166 return false;
167 }
168 } else if (!source.equals(other.source)) {
169 return false;
170 }
171 if (startColumn != other.startColumn) {
172 return false;
173 }
174 if (startLine != other.startLine) {
175 return false;
176 }
177 return true;
178 }
179
126 } 180 }