Iterator<X> () { //noinspection unchecked Iterator<JpsTypedElement<?>> iterator = (Iterator<JpsTypedElement<?>>)myElements.iterator(); return new FilteringIterator<>(iterator, e -> e.getType().equals(myType)); }