| 1 | /* This file is part of Aard Dictionary for Android <http://aarddict.org>. |
| 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 3 |
| 5 | * as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt> |
| 11 | * for more details. |
| 12 | * |
| 13 | * Copyright (C) 2010 Igor Tkach |
| 14 | */ |
| 15 | |
| 16 | package aarddict; |
| 17 | |
| 18 | import java.io.Serializable; |
| 19 | |
| 20 | /** |
| 21 | * @author itkach |
| 22 | */ |
| 23 | public final class Entry implements Serializable { |
| 24 | |
| 25 | public String title; |
| 26 | public String section; |
| 27 | public long articlePointer; |
| 28 | public String volumeId; |
| 29 | |
| 30 | public Entry(String volumeId, String title) { |
| 31 | this(volumeId, title, -1); |
| 32 | } |
| 33 | |
| 34 | public Entry(String volumeId, String title, long articlePointer) { |
| 35 | this.volumeId = volumeId; |
| 36 | this.title = title == null ? "" : title; |
| 37 | this.articlePointer = articlePointer; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public String toString() { |
| 42 | return title; |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public int hashCode() { |
| 47 | final int prime = 31; |
| 48 | int result = 1; |
| 49 | result = prime * result |
| 50 | + (int) (articlePointer ^ (articlePointer >>> 32)); |
| 51 | result = prime * result + ((section == null) ? 0 : section.hashCode()); |
| 52 | result = prime * result + ((title == null) ? 0 : title.hashCode()); |
| 53 | result = prime * result |
| 54 | + ((volumeId == null) ? 0 : volumeId.hashCode()); |
| 55 | return result; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public boolean equals(Object obj) { |
| 60 | if (this == obj) |
| 61 | return true; |
| 62 | if (obj == null) |
| 63 | return false; |
| 64 | if (getClass() != obj.getClass()) |
| 65 | return false; |
| 66 | Entry other = (Entry) obj; |
| 67 | if (articlePointer != other.articlePointer) |
| 68 | return false; |
| 69 | if (section == null) { |
| 70 | if (other.section != null) |
| 71 | return false; |
| 72 | } else if (!section.equals(other.section)) |
| 73 | return false; |
| 74 | if (title == null) { |
| 75 | if (other.title != null) |
| 76 | return false; |
| 77 | } else if (!title.equals(other.title)) |
| 78 | return false; |
| 79 | if (volumeId == null) { |
| 80 | if (other.volumeId != null) |
| 81 | return false; |
| 82 | } else if (!volumeId.equals(other.volumeId)) |
| 83 | return false; |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | } |