提交 c06f6e45 编写于 作者: K Kohsuke Kawaguchi

added another convenience method

上级 b00a6495
......@@ -876,16 +876,12 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
return new Iterable<AbstractBuild<?, ?>>() {
public Iterator<AbstractBuild<?, ?>> iterator() {
return new Iterators.FilterIterator<AbstractBuild<?,?>>(
new AdaptedIterator<Integer,AbstractBuild<?,?>>(nums) {
protected AbstractBuild<?, ?> adapt(Integer item) {
return that.getBuildByNumber(item);
}
}) {
protected boolean filter(AbstractBuild<?,?> build) {
return build!=null;
}
};
return Iterators.removeNull(
new AdaptedIterator<Integer,AbstractBuild<?,?>>(nums) {
protected AbstractBuild<?, ?> adapt(Integer item) {
return that.getBuildByNumber(item);
}
});
}
};
}
......
......@@ -272,6 +272,18 @@ public class Iterators {
};
}
/**
* Wraps another iterator and throws away nulls.
*/
public static <T> Iterator<T> removeNull(final Iterator<T> itr) {
return new FilterIterator<T>(itr) {
@Override
protected boolean filter(T t) {
return t!=null;
}
};
}
/**
* Returns an {@link Iterable} that iterates over all the given {@link Iterable}s.
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册