Collection<VcsRef> () { return new AbstractCollection<>() { private final Supplier<Collection<VcsRef>> myLoadedRefs = Suppliers.memoize(() -> CompressedRefs.this.stream().collect(Collectors.toList())); @Override public @NotNull Iterator<VcsRef> iterator() { return myLoadedRefs.get().iterator(); } @Override public int size() { return myLoadedRefs.get().size(); } }; }