Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
net.jqwik.engine.properties.arbitraries.combinations.DefaultCombinator8 Maven / Gradle / Ivy
package net.jqwik.engine.properties.arbitraries.combinations;
import java.util.*;
import java.util.function.*;
import net.jqwik.api.*;
import org.jspecify.annotations.*;
public class DefaultCombinator8
extends DefaultCombinator7
implements Combinators.Combinator8 {
protected final Arbitrary a8;
public DefaultCombinator8(
Arbitrary a1, Arbitrary a2, Arbitrary a3, Arbitrary a4,
Arbitrary a5, Arbitrary a6, Arbitrary a7, Arbitrary a8
) {
super(a1, a2, a3, a4, a5, a6, a7);
this.a8 = a8;
}
@Override
public Arbitrary as(Combinators.F8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> combinator) {
return new CombineArbitrary<>(combineFunction(combinator), a1, a2, a3, a4, a5, a6, a7, a8);
}
@Override
public Combinators.Combinator8 filter(Combinators.F8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, Boolean> filter) {
return new Filtered<>(a1, a2, a3, a4, a5, a6, a7, a8, filter);
}
@SuppressWarnings("unchecked")
protected Function, R> combineFunction(Combinators.F8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> combinator) {
return params -> combinator.apply(
(T1) params.get(0), (T2) params.get(1),
(T3) params.get(2), (T4) params.get(3),
(T5) params.get(4), (T6) params.get(5),
(T7) params.get(6), (T8) params.get(7)
);
}
private static class Filtered extends DefaultCombinator8 {
private final Combinators.F8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, Boolean> filter;
private Filtered(
Arbitrary a1,
Arbitrary a2,
Arbitrary a3,
Arbitrary a4,
Arbitrary a5,
Arbitrary a6,
Arbitrary a7,
Arbitrary a8,
Combinators.F8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, Boolean> filter
) {
super(a1, a2, a3, a4, a5, a6, a7, a8);
this.filter = filter;
}
@Override
public Arbitrary as(Combinators.F8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> combinator) {
return new CombineArbitrary<>(Function.identity(), a1, a2, a3, a4, a5, a6, a7, a8)
.filter(combineFunction(filter)::apply)
.map(combineFunction(combinator));
}
@Override
public Combinators.Combinator8 filter(Combinators.F8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, Boolean> filter) {
return super.filter(combineFilters(this.filter, filter));
}
private Combinators.F8 combineFilters(
Combinators.F8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, Boolean> first,
Combinators.F8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, Boolean> second
) {
return (p1, p2, p3, p4, p5, p6, p7, p8) -> first.apply(p1, p2, p3, p4, p5, p6, p7, p8) && second.apply(p1, p2, p3, p4, p5, p6, p7, p8);
}
}
}