@Test public void testElementsEqual() { CheckedIterator<String, RuntimeException> iterator; iterator = create("one", "two"); assertTrue(iterator.elementsEqual(create("one", "two"))); iterator = create("one", "two"); assertFalse(iterator.elementsEqual(create("one", "two", "three"))); iterator = create("one", "two"); iterator.next(); assertFalse(iterator.elementsEqual(create("one", "two"))); iterator = create(); CheckedIterator<String, RuntimeException> tmp = create(); assertTrue(iterator.elementsEqual(tmp)); }
public boolean elementsEqual(@NonNull CheckedIterator<E, T> that) throws T { while (this.hasNext()) { if (!that.hasNext()) { return false; } Object o1 = this.next(); Object o2 = that.next(); if (!Objects.equals(o1, o2)) { return false; } } return !that.hasNext(); }
CheckedIterator { public boolean elementsEqual(@NonNull CheckedIterator<E, T> that) throws T { while (this.hasNext()) { if (!that.hasNext()) { return false; } Object o1 = this.next(); Object o2 = that.next(); if (!Objects.equals(o1, o2)) { return false; } } return !that.hasNext(); } }
CheckedIterator { public boolean elementsEqual(@NonNull CheckedIterator<E, T> that) throws T { while (this.hasNext()) { if (!that.hasNext()) { return false; } Object o1 = this.next(); Object o2 = that.next(); if (!Objects.equals(o1, o2)) { return false; } } return !that.hasNext(); }  }
CheckedIterator { public boolean elementsEqual(@NonNull CheckedIterator<E, T> that) throws T { while (this.hasNext()) { if (!that.hasNext()) { return false; } Object o1 = this.next(); Object o2 = that.next(); if (!Objects.equals(o1, o2)) { return false; } } return !that.hasNext(); }  abstract boolean hasNext(); @Nullable abstract E next(); @Nullable E next(@Nullable E defaultValue); int count(); boolean copyInto(@NonNull Collection<? super E> collection); @NonNull List<E> toList(); @NonNull E[] toArray(@NonNull Class<E> type); @NonNull Map<E, V> toMap(@NonNull Function<? super E, V> valueFunc); @NonNull Map<K, V> toMap(@NonNull Function<? super E, K> keyFunc, @NonNull Function<? super E, V> valueFunc); @Nullable E getLast(); @Nullable E getLast(@Nullable E defaultValue); @Nullable E get(int position); @Nullable E get(int position, @Nullable E defaultValue); boolean all(@NonNull Predicate<? super E> predicate); boolean any(@NonNull Predicate<? super E> predicate); int indexOf(@NonNull Predicate<? super E> predicate); boolean contains(@Nullable E element); boolean elementsEqual(@NonNull CheckedIterator<E, T> that); @Nullable E find(@NonNull Predicate<? super E> predicate); @Nullable E find(@NonNull Predicate<? super E> predicate, @Nullable E defaultValue); int frequency(@Nullable E element); @NonNull CheckedIterator<E, T> filter(@NonNull final Predicate<? super E> predicate); @NonNull CheckedIterator<E, T> filter(@NonNull Class<? extends E> type); @NonNull CheckedIterator<E, T> skip(final int skipSize); @NonNull CheckedIterator<E, T> limit(final int limitSize); @NonNull CheckedIterator<NEW, T> transform(@NonNull final Function<? super E, ? extends NEW> function); @NonNull CheckedIterator<E, T> concat(@NonNull CheckedIterator<E, T> input); @NonNull static CheckedIterator<E, T> emptyIterator(); @NonNull static CheckedIterator<X, RuntimeException> fromIterator(@NonNull final Iterator<X> iterator); @NonNull static CheckedIterator<String, IOException> fromBufferedReader(@NonNull final BufferedReader reader); }
CheckedIterator { public boolean elementsEqual(@NonNull CheckedIterator<E, T> that) throws T { while (this.hasNext()) { if (!that.hasNext()) { return false; } Object o1 = this.next(); Object o2 = that.next(); if (!Objects.equals(o1, o2)) { return false; } } return !that.hasNext(); }  abstract boolean hasNext(); @Nullable abstract E next(); @Nullable E next(@Nullable E defaultValue); int count(); boolean copyInto(@NonNull Collection<? super E> collection); @NonNull List<E> toList(); @NonNull E[] toArray(@NonNull Class<E> type); @NonNull Map<E, V> toMap(@NonNull Function<? super E, V> valueFunc); @NonNull Map<K, V> toMap(@NonNull Function<? super E, K> keyFunc, @NonNull Function<? super E, V> valueFunc); @Nullable E getLast(); @Nullable E getLast(@Nullable E defaultValue); @Nullable E get(int position); @Nullable E get(int position, @Nullable E defaultValue); boolean all(@NonNull Predicate<? super E> predicate); boolean any(@NonNull Predicate<? super E> predicate); int indexOf(@NonNull Predicate<? super E> predicate); boolean contains(@Nullable E element); boolean elementsEqual(@NonNull CheckedIterator<E, T> that); @Nullable E find(@NonNull Predicate<? super E> predicate); @Nullable E find(@NonNull Predicate<? super E> predicate, @Nullable E defaultValue); int frequency(@Nullable E element); @NonNull CheckedIterator<E, T> filter(@NonNull final Predicate<? super E> predicate); @NonNull CheckedIterator<E, T> filter(@NonNull Class<? extends E> type); @NonNull CheckedIterator<E, T> skip(final int skipSize); @NonNull CheckedIterator<E, T> limit(final int limitSize); @NonNull CheckedIterator<NEW, T> transform(@NonNull final Function<? super E, ? extends NEW> function); @NonNull CheckedIterator<E, T> concat(@NonNull CheckedIterator<E, T> input); @NonNull static CheckedIterator<E, T> emptyIterator(); @NonNull static CheckedIterator<X, RuntimeException> fromIterator(@NonNull final Iterator<X> iterator); @NonNull static CheckedIterator<String, IOException> fromBufferedReader(@NonNull final BufferedReader reader);  }