Clean up IteratorUtil.filter
Use method references where possible. Remove no-longer-needed annotations.
This commit is contained in:
parent
5fa3643652
commit
b2e1081221
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.util.collections;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Function;
|
||||
/**
|
||||
* utilities dealing with Iterators
|
||||
*/
|
||||
|
@ -45,14 +44,6 @@ public class IteratorUtil {
|
|||
}
|
||||
|
||||
public static <T, S extends T> Iterator<S> filter(Iterator<T> iterator, final Class<S> cls) {
|
||||
return new MapIterator<>(
|
||||
new FilterIterator<>(iterator, cls::isInstance),
|
||||
new Function<T,S>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public S apply(T object) {
|
||||
return (S) object;
|
||||
}
|
||||
});
|
||||
return new MapIterator<>(new FilterIterator<>(iterator, cls::isInstance), cls::cast);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue