void () { Integer base = 5; JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).take(10).filter(new JBIterable.SCond<>() { IntSet visited; // MUST NOT be initialized here @Override public boolean value(Integer integer) { if (visited == null) { visited = new IntOpenHashSet(); } return visited.add(integer % base); } }); assertEquals(Arrays.asList(1, 2, 3, 4, 5), it.toList()); assertEquals(Arrays.asList(1, 2, 3, 4, 5), it.toList()); }