# HG changeset patch # User Chris Seaton # Date 1369524665 25200 # Node ID e210293dca77153edefde40607acb470072e3a25 # Parent 32d8115dade8e3ce12de47695fb900df4b8784e4 Generated hashCode and equals for SourceSection. Source is abstract, so just uses identity methods for that. diff -r 32d8115dade8 -r e210293dca77 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java Sun May 26 00:01:38 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java Sat May 25 16:31:05 2013 -0700 @@ -123,4 +123,58 @@ return String.format("%s:%d", source.getName(), startLine); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + charIndex; + result = prime * result + charLength; + result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); + result = prime * result + ((source == null) ? 0 : source.hashCode()); + result = prime * result + startColumn; + result = prime * result + startLine; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof SourceSection)) { + return false; + } + SourceSection other = (SourceSection) obj; + if (charIndex != other.charIndex) { + return false; + } + if (charLength != other.charLength) { + return false; + } + if (identifier == null) { + if (other.identifier != null) { + return false; + } + } else if (!identifier.equals(other.identifier)) { + return false; + } + if (source == null) { + if (other.source != null) { + return false; + } + } else if (!source.equals(other.source)) { + return false; + } + if (startColumn != other.startColumn) { + return false; + } + if (startLine != other.startLine) { + return false; + } + return true; + } + }