Java 类org.jooq.lambda.tuple.Tuple4 实例源码

项目:RankSys    文件:SimplePreferenceData.java   
/**
 * Loads an instance of the class from a stream of tuples possibly containing extra information.
 *
 * @param <U> type of user
 * @param <I> type of item
 * @param <O> type of additional information
 * @param tuples stream of user-item-value triples
 * @param uPrefFun creator of preference objects
 * @param iPrefFun creator of preference objects
 * @return a preference data object
 */
public static <U, I, O> SimplePreferenceData<U, I> load(Stream<Tuple4<U, I, Double, O>> tuples,
                                                        Function4<U, I, Double, O, ? extends IdPref<I>> uPrefFun,
                                                        Function4<U, I, Double, O, ? extends IdPref<U>> iPrefFun) {
    AtomicInteger numPreferences = new AtomicInteger(0);
    Map<U, List<IdPref<I>>> userMap = new HashMap<>();
    Map<I, List<IdPref<U>>> itemMap = new HashMap<>();

    tuples.forEach(t -> {
        numPreferences.incrementAndGet();
        userMap.computeIfAbsent(t.v1, v1 -> new ArrayList<>()).add(uPrefFun.apply(t));
        itemMap.computeIfAbsent(t.v2, v2 -> new ArrayList<>()).add(iPrefFun.apply(t));
    });

    return new SimplePreferenceData<>(userMap, itemMap, numPreferences.intValue());
}
项目:jOOL    文件:Seq.java   
/**
 * Map this stream to a windowed stream with 4 distinct windows.
 */
@Generated("This method was generated using jOOQ-tools")
default Seq<Tuple4<Window<T>, Window<T>, Window<T>, Window<T>>> window(
    WindowSpecification<T> specification1,
    WindowSpecification<T> specification2,
    WindowSpecification<T> specification3,
    WindowSpecification<T> specification4
) {
    List<Tuple2<T, Long>> buffer = zipWithIndex().toList();

    Map<?, Partition<T>> partitions1 = SeqUtils.partitions(specification1, buffer);
    Map<?, Partition<T>> partitions2 = SeqUtils.partitions(specification2, buffer);
    Map<?, Partition<T>> partitions3 = SeqUtils.partitions(specification3, buffer);
    Map<?, Partition<T>> partitions4 = SeqUtils.partitions(specification4, buffer);

    return seq(buffer)
          .map(t -> tuple(
               (Window<T>) new WindowImpl<>(t, partitions1.get(specification1.partition().apply(t.v1)), specification1),
               (Window<T>) new WindowImpl<>(t, partitions2.get(specification2.partition().apply(t.v1)), specification2),
               (Window<T>) new WindowImpl<>(t, partitions3.get(specification3.partition().apply(t.v1)), specification3),
               (Window<T>) new WindowImpl<>(t, partitions4.get(specification4.partition().apply(t.v1)), specification4)
          ))
          .onClose(this::close);
}
项目:jOOL    文件:Collectable.java   
/**
 * Collect this collectable into 4 {@link Collector}s.
 */
@Generated("This method was generated using jOOQ-tools")
default <R1, R2, R3, R4, A1, A2, A3, A4> Tuple4<R1, R2, R3, R4> collect(
    Collector<? super T, A1, R1> collector1,
    Collector<? super T, A2, R2> collector2,
    Collector<? super T, A3, R3> collector3,
    Collector<? super T, A4, R4> collector4
) {
    return collect(Tuple.collectors(collector1, collector2, collector3, collector4));
}
项目:jOOL    文件:Seq.java   
/**
 * Cross join 4 streams into one.
 * <p>
 * <code><pre>
 * // (tuple(1, "a"), tuple(1, "b"), tuple(2, "a"), tuple(2, "b"))
 * Seq.of(1, 2).crossJoin(Seq.of("a", "b"))
 * </pre></code>
 */
@Generated("This method was generated using jOOQ-tools")
static <T1, T2, T3, T4> Seq<Tuple4<T1, T2, T3, T4>> crossJoin(Seq<? extends T1> s1, Seq<? extends T2> s2, Seq<? extends T3> s3, Seq<? extends T4> s4) {

    // [#323] Some explicit type variable bindings required because of compiler regressions in JDK 9
    List<Tuple3<T2, T3, T4>> list = Seq.<T2, T3, T4>crossJoin(s2, s3, s4).toList();
    return s1.flatMap(v1 -> seq(list).map(t -> tuple(v1, t.v1, t.v2, t.v3)))
             .onClose(SeqUtils.closeAll(s2, s3, s4));
}
项目:jOOL    文件:Seq.java   
/**
 * Cross join 5 streams into one.
 * <p>
 * <code><pre>
 * // (tuple(1, "a"), tuple(1, "b"), tuple(2, "a"), tuple(2, "b"))
 * Seq.of(1, 2).crossJoin(Seq.of("a", "b"))
 * </pre></code>
 */
@Generated("This method was generated using jOOQ-tools")
static <T1, T2, T3, T4, T5> Seq<Tuple5<T1, T2, T3, T4, T5>> crossJoin(Seq<? extends T1> s1, Seq<? extends T2> s2, Seq<? extends T3> s3, Seq<? extends T4> s4, Seq<? extends T5> s5) {

    // [#323] Some explicit type variable bindings required because of compiler regressions in JDK 9
    List<Tuple4<T2, T3, T4, T5>> list = Seq.<T2, T3, T4, T5>crossJoin(s2, s3, s4, s5).toList();
    return s1.flatMap(v1 -> seq(list).map(t -> tuple(v1, t.v1, t.v2, t.v3, t.v4)))
             .onClose(SeqUtils.closeAll(s2, s3, s4, s5));
}
项目:json2java4idea    文件:DefaultNamePolicyTest.java   
@Parameters(name = "{0}")
public static Collection<Tuple4<DefaultNamePolicy, String, TypeName, String>> fixtures() {
    return Arrays.asList(
            Tuple.tuple(
                    DefaultNamePolicy.CLASS,
                    "class_name",
                    TypeName.OBJECT,
                    "ClassName"
            ),
            Tuple.tuple(
                    DefaultNamePolicy.METHOD,
                    "method_name",
                    TypeName.OBJECT,
                    "getMethodName"
            ),
            Tuple.tuple(
                    DefaultNamePolicy.METHOD,
                    "method_name",
                    TypeName.BOOLEAN,
                    "isMethodName"
            ),
            Tuple.tuple(
                    DefaultNamePolicy.METHOD,
                    "method_name",
                    ClassName.get(Boolean.class),
                    "isMethodName"
            ),
            Tuple.tuple(
                    DefaultNamePolicy.FIELD,
                    "field_name",
                    TypeName.OBJECT,
                    "fieldName"
            ),
            Tuple.tuple(
                    DefaultNamePolicy.PARAMETER,
                    "parameter_name",
                    TypeName.OBJECT,
                    "parameterName"
            )
    );
}
项目:json2java4idea    文件:DefaultNamePolicyTest.java   
public EnumTest(@Nonnull Tuple4<DefaultNamePolicy, String, TypeName, String> fixture) {
    underTest = fixture.v1();
    name = fixture.v2();
    type = fixture.v3();
    expected = fixture.v4();
}
项目:jOOL    文件:Function14.java   
/**
 * Partially apply this function to the arguments.
 */
default Function10<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14);
}
项目:jOOL    文件:Consumer6.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer2<T5, T6> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6);
}
项目:jOOL    文件:Consumer7.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer3<T5, T6, T7> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6, v7);
}
项目:jOOL    文件:Function9.java   
/**
 * Partially apply this function to the arguments.
 */
default Function5<T5, T6, T7, T8, T9, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9);
}
项目:jOOL    文件:Function4.java   
/**
 * Partially apply this function to the arguments.
 */
default Function0<R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return () -> apply(args.v1, args.v2, args.v3, args.v4);
}
项目:jOOL    文件:Consumer16.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer12<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16);
}
项目:jOOL    文件:Function10.java   
/**
 * Partially apply this function to the arguments.
 */
default Function6<T5, T6, T7, T8, T9, T10, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10);
}
项目:jOOL    文件:Function11.java   
/**
 * Partially apply this function to the arguments.
 */
default Function7<T5, T6, T7, T8, T9, T10, T11, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11);
}
项目:jOOL    文件:Function7.java   
/**
 * Partially apply this function to the arguments.
 */
default Function3<T5, T6, T7, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7);
}
项目:jOOL    文件:Function16.java   
/**
 * Partially apply this function to the arguments.
 */
default Function12<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16);
}
项目:jOOL    文件:Consumer10.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer6<T5, T6, T7, T8, T9, T10> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10);
}
项目:jOOL    文件:Consumer14.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer10<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14);
}
项目:jOOL    文件:Consumer8.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer4<T5, T6, T7, T8> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8);
}
项目:jOOL    文件:Consumer13.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer9<T5, T6, T7, T8, T9, T10, T11, T12, T13> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12, v13) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);
}
项目:jOOL    文件:Consumer9.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer5<T5, T6, T7, T8, T9> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9);
}
项目:jOOL    文件:Function6.java   
/**
 * Partially apply this function to the arguments.
 */
default Function2<T5, T6, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6);
}
项目:jOOL    文件:Consumer15.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer11<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15);
}
项目:jOOL    文件:Function15.java   
/**
 * Partially apply this function to the arguments.
 */
default Function11<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15);
}
项目:jOOL    文件:Function5.java   
/**
 * Partially apply this function to the arguments.
 */
default Function1<T5, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5) -> apply(args.v1, args.v2, args.v3, args.v4, v5);
}
项目:jOOL    文件:Function12.java   
/**
 * Partially apply this function to the arguments.
 */
default Function8<T5, T6, T7, T8, T9, T10, T11, T12, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12);
}
项目:jOOL    文件:Function8.java   
/**
 * Partially apply this function to the arguments.
 */
default Function4<T5, T6, T7, T8, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8);
}
项目:jOOL    文件:Consumer11.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer7<T5, T6, T7, T8, T9, T10, T11> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11);
}
项目:jOOL    文件:Function13.java   
/**
 * Partially apply this function to the arguments.
 */
default Function9<T5, T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12, v13) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);
}
项目:jOOL    文件:Consumer4.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer0 acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return () -> accept(args.v1, args.v2, args.v3, args.v4);
}
项目:jOOL    文件:Consumer12.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer8<T5, T6, T7, T8, T9, T10, T11, T12> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12) -> accept(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12);
}
项目:jOOL    文件:Consumer5.java   
/**
 * Let this consumer partially accept the arguments.
 */
default Consumer1<T5> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5) -> accept(args.v1, args.v2, args.v3, args.v4, v5);
}
项目:jOOL    文件:Example.java   
public static void main(String[] args) {
    List<Person> personsList = new ArrayList<>();

    personsList.add(new Person("John", "Doe", 25, 1.80, 80));
    personsList.add(new Person("Jane", "Doe", 30, 1.69, 60));
    personsList.add(new Person("John", "Smith", 35, 174, 70));

    Tuple4<Long, Optional<Integer>, Optional<Double>, Optional<Double>> r1 =
    Seq.seq(personsList)
       .filter(p -> p.getFirstName().equals("John"))
       .collect(
            Agg.count(),
            Agg.max(Person::getAge),
            Agg.min(Person::getHeight),
            Agg.avg(Person::getWeight)
       );

    System.out.println(r1);
    System.out.println();

    System.out.println(
        Seq.of("a", "a", "a", "b", "c", "c", "d", "e")
           .window(naturalOrder())
           .map(w -> tuple(
                w.value(),
                w.rowNumber(),
                w.rank(),
                w.denseRank()
           ))
           .format()
    );
    System.out.println();


    System.out.println(
        Seq.of("a", "a", "a", "b", "c", "c", "d", "e")
           .window(naturalOrder())
           .map(w -> tuple(
                w.value(),
                w.count(),
                w.median(),
                w.lead(),
                w.lag(),
                w.toString()
           ))
           .format()
    );
    System.out.println();


    BigDecimal currentBalance = new BigDecimal("19985.81");

    System.out.println(
        Seq.of(
                tuple(9997, "2014-03-18", new BigDecimal("99.17")),
                tuple(9981, "2014-03-16", new BigDecimal("71.44")),
                tuple(9979, "2014-03-16", new BigDecimal("-94.60")),
                tuple(9977, "2014-03-16", new BigDecimal("-6.96")),
                tuple(9971, "2014-03-15", new BigDecimal("-65.95")))
           .window(Comparator.comparing((Tuple3<Integer, String, BigDecimal> t) -> t.v1, reverseOrder()).thenComparing(t -> t.v2), Long.MIN_VALUE, -1)
           .map(w -> w.value().concat(
                currentBalance.subtract(w.sum(t -> t.v3).orElse(BigDecimal.ZERO))
           ))
           .format()
    );
    System.out.println();

    System.out.println(
    Seq.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
        .window(i -> i % 2, -1, 1)
        .map(w -> tuple(w.value(), w.sum()))

        .format());
}
项目:jOOL    文件:Seq.java   
/**
 * Cross apply 4 functions to a stream.
 * <p>
 * <code><pre>
 * // (tuple(1, 0), tuple(2, 0), tuple(2, 1))
 * Seq.of(1, 2).crossApply(t -> Seq.range(0, t))
 * </pre></code>
 */
@Generated("This method was generated using jOOQ-tools")
static <T1, T2, T3, T4> Seq<Tuple4<T1, T2, T3, T4>> crossApply(Seq<? extends T1> seq, Function<? super T1, ? extends Seq<? extends T2>> function2, Function<? super T2, ? extends Seq<? extends T3>> function3, Function<? super T3, ? extends Seq<? extends T4>> function4) {
    return seq.flatMap(t1 -> function2.apply(t1).map(t2 -> tuple(t1, t2)))
              .flatMap(t -> function3.apply(t.v2).map(t3 -> t.concat(t3)))
              .flatMap(t -> function4.apply(t.v3).map(t4 -> t.concat(t4)))
              .onClose(seq::close);
}
项目:jOOL    文件:Seq.java   
/**
 * Outer apply 4 functions to a stream.
 * <p>
 * <code><pre>
 * // (tuple(0, null), tuple(1, 0), tuple(2, 0), tuple(2, 1))
 * Seq.of(0, 1, 2).outerApply(t -> Seq.range(0, t))
 * </pre></code>
 */
@Generated("This method was generated using jOOQ-tools")
static <T1, T2, T3, T4> Seq<Tuple4<T1, T2, T3, T4>> outerApply(Seq<? extends T1> seq, Function<? super T1, ? extends Seq<? extends T2>> function2, Function<? super T2, ? extends Seq<? extends T3>> function3, Function<? super T3, ? extends Seq<? extends T4>> function4) {
    return seq.flatMap(t1 -> function2.apply(t1).onEmpty(null).map(t2 -> tuple(t1, t2)))
              .flatMap(t -> function3.apply(t.v2).onEmpty(null).map(t3 -> t.concat(t3)))
              .flatMap(t -> function4.apply(t.v3).onEmpty(null).map(t4 -> t.concat(t4)))
              .onClose(seq::close);
}
项目:RankSys    文件:SimplePreferenceData.java   
/**
 * Loads a SimplePreferenceData from a stream of user-item-value triples.
 *
 * @param <U> user type
 * @param <I> item type
 * @param tuples user-item-value triples
 * @return instance of SimplePreferenceData containing the information in the input
 */
public static <U, I> SimplePreferenceData<U, I> load(Stream<Tuple3<U, I, Double>> tuples) {
    return load((Stream<Tuple4<U, I, Double, Void>>) tuples.map(t -> t.concat((Void) null)),
            (u, i, v, o) -> new IdPref<>(i, v), (u, i, v, o) -> new IdPref<>(u, v));
}
项目:jOOL    文件:Function14.java   
/**
 * Partially apply this function to the arguments.
 *
 * @deprecated - Use {@link #applyPartially(Tuple4)} instead.
 */
@Deprecated
default Function10<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> curry(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14);
}
项目:jOOL    文件:Function9.java   
/**
 * Partially apply this function to the arguments.
 *
 * @deprecated - Use {@link #applyPartially(Tuple4)} instead.
 */
@Deprecated
default Function5<T5, T6, T7, T8, T9, R> curry(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return (v5, v6, v7, v8, v9) -> apply(args.v1, args.v2, args.v3, args.v4, v5, v6, v7, v8, v9);
}
项目:jOOL    文件:Function4.java   
/**
 * Apply this function to the arguments.
 *
 * @param args The arguments as a tuple.
 */
default R apply(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) {
    return apply(args.v1, args.v2, args.v3, args.v4);
}