BlobCitationEntry implements Comparable<BlobCitationEntry> { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BlobCitationEntry other = (BlobCitationEntry) obj; if (identifiers == null) { if (other.identifiers != null) return false; } else if (!identifiers.equals(other.identifiers)) return false; if (position != other.position) return false; if (rawText == null) { if (other.rawText != null) return false; } else if (!rawText.equals(other.rawText)) return false; return true; } BlobCitationEntry();  BlobCitationEntry(String rawText); String getRawText(); void setRawText(String rawText); List<TypedId> getIdentifiers(); void setIdentifiers(List<TypedId> identifiers); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(BlobCitationEntry c2); int getPosition(); void setPosition(int position);  }
@Test public void testEquals() throws Exception { String rawText = "some raw text"; int position = 1; List<TypedId> identifiers = Lists.newArrayList(new TypedId("someValue", "someType", 0.9f)); BlobCitationEntry blobCitationEntry = new BlobCitationEntry(rawText); blobCitationEntry.setPosition(position); blobCitationEntry.setIdentifiers(identifiers); assertFalse(blobCitationEntry.equals(null)); assertFalse(blobCitationEntry.equals("string")); BlobCitationEntry otherBlobCitationEntry = new BlobCitationEntry("other raw text"); otherBlobCitationEntry.setPosition(position); otherBlobCitationEntry.setIdentifiers(identifiers); assertFalse(blobCitationEntry.equals(otherBlobCitationEntry)); otherBlobCitationEntry = new BlobCitationEntry(rawText); otherBlobCitationEntry.setPosition(2); otherBlobCitationEntry.setIdentifiers(identifiers); assertFalse(blobCitationEntry.equals(otherBlobCitationEntry)); otherBlobCitationEntry = new BlobCitationEntry(rawText); otherBlobCitationEntry.setPosition(position); otherBlobCitationEntry.setIdentifiers(Lists.newArrayList(new TypedId("someOtherValue", "someType", 0.9f))); assertFalse(blobCitationEntry.equals(otherBlobCitationEntry)); otherBlobCitationEntry = new BlobCitationEntry(rawText); otherBlobCitationEntry.setPosition(position); otherBlobCitationEntry.setIdentifiers(identifiers); assertTrue(blobCitationEntry.equals(otherBlobCitationEntry)); }