net.openhft.chronicle.testframework.Product Maven / Gradle / Ivy
package net.openhft.chronicle.testframework;
import net.openhft.chronicle.testframework.internal.ProductUtil;
import java.util.Collection;
import java.util.function.BiFunction;
import java.util.stream.Stream;
import static java.util.Objects.requireNonNull;
public final class Product {
// Suppresses default constructor, ensuring non-instantiability.
private Product() {
}
public static Stream> of(Collection ts,
Collection us) {
requireNonNull(ts);
requireNonNull(us);
return of(ts, us, ProductUtil.Product2Impl::new);
}
public static Stream of(Collection ts,
Collection us,
BiFunction super T, ? super U, ? extends R> constructor) {
requireNonNull(ts);
requireNonNull(us);
requireNonNull(constructor);
return ProductUtil.of(ts, us, constructor);
}
public static Stream> of(Collection ts,
Collection us,
Collection vs) {
requireNonNull(ts);
requireNonNull(us);
requireNonNull(vs);
return of(ts, us, vs, ProductUtil.Product3Impl::new);
}
public static Stream of(Collection ts,
Collection us,
Collection vs,
TriFunction constructor) {
requireNonNull(ts);
requireNonNull(us);
requireNonNull(vs);
requireNonNull(constructor);
return ProductUtil.of(ts, us, vs, constructor);
}
@FunctionalInterface
public interface TriFunction {
/**
* Applies this function to the given arguments.
*
* @param t the first function argument
* @param u the second function argument
* @param v the third function argument
* @return the function result
*/
R apply(T t, U u, V v);
}
public interface HasFirst {
T first();
}
public interface HasSecond {
U second();
}
public interface HasThird {
V third();
}
public interface Product2 extends HasFirst, HasSecond {
}
public interface Product3 extends HasFirst, HasSecond, HasThird {
}
}