@Test public void readTwice() { assertSame(ZERO, seq.get(0)); verify(underlying, times(1)).get(0); assertSame(ZERO, seq.get(0)); verifyNoMoreInteractions(underlying); }
@Override public T get(int index) { if (index < 0 || index >= size()) throw new NoSuchElementException("index " + index + " out of bounds [0.." + size() + ")"); return cache[index].resolve(() -> underlying.get(index), referenceBuilder); }
CachingObjectSequence implements ObjectSequence<T> { @Override public T get(int index) { if (index < 0 || index >= size()) throw new NoSuchElementException("index " + index + " out of bounds [0.." + size() + ")"); return cache[index].resolve(() -> underlying.get(index), referenceBuilder); } }
CachingObjectSequence implements ObjectSequence<T> { @Override public T get(int index) { if (index < 0 || index >= size()) throw new NoSuchElementException("index " + index + " out of bounds [0.." + size() + ")"); return cache[index].resolve(() -> underlying.get(index), referenceBuilder); } CachingObjectSequence(@NonNull ObjectSequence<T> underlying, @NonNull Function<T, ? extends Reference<T>> referenceBuilder); }
CachingObjectSequence implements ObjectSequence<T> { @Override public T get(int index) { if (index < 0 || index >= size()) throw new NoSuchElementException("index " + index + " out of bounds [0.." + size() + ")"); return cache[index].resolve(() -> underlying.get(index), referenceBuilder); } CachingObjectSequence(@NonNull ObjectSequence<T> underlying, @NonNull Function<T, ? extends Reference<T>> referenceBuilder); @Override boolean isSorted(); @Override boolean isNonnull(); @Override boolean isDistinct(); @Override T get(int index); @Override Comparator<C> getComparator(); @Override Iterator<T> iterator(); @Override Spliterator<T> spliterator(); @Override Stream<T> stream(); @Override Stream<T> parallelStream(); @Override int size(); @Override boolean isEmpty(); @Override ObjectSequence<T> reverse(); }
CachingObjectSequence implements ObjectSequence<T> { @Override public T get(int index) { if (index < 0 || index >= size()) throw new NoSuchElementException("index " + index + " out of bounds [0.." + size() + ")"); return cache[index].resolve(() -> underlying.get(index), referenceBuilder); } CachingObjectSequence(@NonNull ObjectSequence<T> underlying, @NonNull Function<T, ? extends Reference<T>> referenceBuilder); @Override boolean isSorted(); @Override boolean isNonnull(); @Override boolean isDistinct(); @Override T get(int index); @Override Comparator<C> getComparator(); @Override Iterator<T> iterator(); @Override Spliterator<T> spliterator(); @Override Stream<T> stream(); @Override Stream<T> parallelStream(); @Override int size(); @Override boolean isEmpty(); @Override ObjectSequence<T> reverse();  }