@Test public void testIsEqual() { DocumentSet set1 = docSet(Document.keyComparator(), DOC1, DOC2, DOC3); DocumentSet set2 = docSet(Document.keyComparator(), DOC1, DOC2, DOC3); assertEquals(set1, set1); assertEquals(set1, set2); assertFalse(set1.equals(null)); DocumentSet sortedSet1 = docSet(TEST_COMPARATOR, DOC1, DOC2, DOC3); DocumentSet sortedSet2 = docSet(TEST_COMPARATOR, DOC1, DOC2, DOC3); assertEquals(sortedSet1, sortedSet1); assertEquals(sortedSet1, sortedSet2); assertFalse(sortedSet1.equals(null)); DocumentSet shortSet = docSet(Document.keyComparator(), DOC1, DOC2); assertNotEquals(set1, shortSet); assertNotEquals(set1, sortedSet1); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } DocumentSet documentSet = (DocumentSet) other; if (size() != documentSet.size()) { return false; } Iterator<Document> thisIterator = iterator(); Iterator<Document> otherIterator = documentSet.iterator(); while (thisIterator.hasNext()) { Document thisDoc = thisIterator.next(); Document otherDoc = otherIterator.next(); if (!thisDoc.equals(otherDoc)) { return false; } } return true; }
DocumentSet implements Iterable<Document> { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } DocumentSet documentSet = (DocumentSet) other; if (size() != documentSet.size()) { return false; } Iterator<Document> thisIterator = iterator(); Iterator<Document> otherIterator = documentSet.iterator(); while (thisIterator.hasNext()) { Document thisDoc = thisIterator.next(); Document otherDoc = otherIterator.next(); if (!thisDoc.equals(otherDoc)) { return false; } } return true; } }
DocumentSet implements Iterable<Document> { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } DocumentSet documentSet = (DocumentSet) other; if (size() != documentSet.size()) { return false; } Iterator<Document> thisIterator = iterator(); Iterator<Document> otherIterator = documentSet.iterator(); while (thisIterator.hasNext()) { Document thisDoc = thisIterator.next(); Document otherDoc = otherIterator.next(); if (!thisDoc.equals(otherDoc)) { return false; } } return true; } private  DocumentSet(
      ImmutableSortedMap<DocumentKey, Document> keyIndex, ImmutableSortedSet<Document> sortedSet); }
DocumentSet implements Iterable<Document> { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } DocumentSet documentSet = (DocumentSet) other; if (size() != documentSet.size()) { return false; } Iterator<Document> thisIterator = iterator(); Iterator<Document> otherIterator = documentSet.iterator(); while (thisIterator.hasNext()) { Document thisDoc = thisIterator.next(); Document otherDoc = otherIterator.next(); if (!thisDoc.equals(otherDoc)) { return false; } } return true; } private  DocumentSet(
      ImmutableSortedMap<DocumentKey, Document> keyIndex, ImmutableSortedSet<Document> sortedSet); static DocumentSet emptySet(final Comparator<Document> comparator); int size(); boolean isEmpty(); boolean contains(DocumentKey key); @Nullable Document getDocument(DocumentKey key); @Nullable Document getFirstDocument(); @Nullable Document getLastDocument(); @Nullable Document getPredecessor(DocumentKey key); int indexOf(DocumentKey key); DocumentSet add(Document document); DocumentSet remove(DocumentKey key); List<Document> toList(); @Override @NonNull Iterator<Document> iterator(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); }
DocumentSet implements Iterable<Document> { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } DocumentSet documentSet = (DocumentSet) other; if (size() != documentSet.size()) { return false; } Iterator<Document> thisIterator = iterator(); Iterator<Document> otherIterator = documentSet.iterator(); while (thisIterator.hasNext()) { Document thisDoc = thisIterator.next(); Document otherDoc = otherIterator.next(); if (!thisDoc.equals(otherDoc)) { return false; } } return true; } private  DocumentSet(
      ImmutableSortedMap<DocumentKey, Document> keyIndex, ImmutableSortedSet<Document> sortedSet); static DocumentSet emptySet(final Comparator<Document> comparator); int size(); boolean isEmpty(); boolean contains(DocumentKey key); @Nullable Document getDocument(DocumentKey key); @Nullable Document getFirstDocument(); @Nullable Document getLastDocument(); @Nullable Document getPredecessor(DocumentKey key); int indexOf(DocumentKey key); DocumentSet add(Document document); DocumentSet remove(DocumentKey key); List<Document> toList(); @Override @NonNull Iterator<Document> iterator(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }