
org.openclover.util.function.Streams Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clover Show documentation
Show all versions of clover Show documentation
Clover is an award winning code coverage and testing tool for Java and Groovy.
It integrates easily with Maven, Ant, Grails, Eclipse and IntelliJ IDEA
as well as with continuous integration servers such as Bamboo, Jenkins or Hudson.
Note: before Clover 4.0 this artifact was named com.cenqua.clover:clover.
The newest version!
package org.openclover.util.function;
import java.util.ArrayList;
import java.util.Collection;
/**
* @deprecated Will be replaced by Java streams API once support for JDK7 is dropped.
*/
public abstract class Streams {
public static Collection filter(Collection source, Predicate super S> predicate) {
final Collection target = new ArrayList<>();
for (S element : source) {
if (predicate.test(element)) {
target.add(element);
}
}
return target;
}
public static Collection map(Collection source, Function super S, T> function) {
final Collection target = new ArrayList<>();
for (S element : source) {
target.add(function.apply(element));
}
return target;
}
public static boolean matchesAny(Collection source, Predicate super S> predicate) {
for (S element : source) {
if (predicate.test(element)) {
return true;
}
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy