修訂 | f06b93d715a12eac3c572f5d7aaa9f13c40ac058 (tree) |
---|---|
時間 | 2013-10-15 23:56:07 |
作者 | MobiDevelop <support@mobi...> |
Commiter | MobiDevelop |
Merge pull request #824 from MobiDevelop/filehandle-equals
Override equals and hashCode on FileHandle
@@ -579,6 +579,21 @@ public class FileHandle { | ||
579 | 579 | return file().lastModified(); |
580 | 580 | } |
581 | 581 | |
582 | + @Override | |
583 | + public boolean equals (Object obj) { | |
584 | + if (!(obj instanceof FileHandle)) return false; | |
585 | + FileHandle other = (FileHandle)obj; | |
586 | + return type == other.type && path().equals(other.path()); | |
587 | + } | |
588 | + | |
589 | + @Override | |
590 | + public int hashCode () { | |
591 | + int hash = 1; | |
592 | + hash = hash * 37 + type.hashCode(); | |
593 | + hash = hash * 67 + path().hashCode(); | |
594 | + return hash; | |
595 | + } | |
596 | + | |
582 | 597 | public String toString () { |
583 | 598 | return file.getPath().replace('\\', '/'); |
584 | 599 | } |