<commit_before>package play.libs;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import play.core.Invoker;

/**
 * Defines a set of functional programming style helpers.
 */
public class F {

    /**
     * A Callback with no arguments.
     */
    public static interface Callback0 {
        public void invoke() throws Throwable;
    }

    /**
     * A Callback with a single argument.
     */
    public static interface Callback<A> {
        public void invoke(A a) throws Throwable;
    }

    /**
     * A Callback with 2 arguments.
     */
    public static interface Callback2<A,B> {
        public void invoke(A a, B b) throws Throwable;
    }

    /**
     * A Callback with 3 arguments.
     */
    public static interface Callback3<A,B,C> {
        public void invoke(A a, B b, C c) throws Throwable;
    }

    /**
     * A Function with no arguments.
     */
    public static interface Function0<R> {
        public R apply() throws Throwable;
    }

    /**
     * A Function with a single argument.
     */
    public static interface Function<A,R> {
        public R apply(A a) throws Throwable;
    }

    /**
     * A Function with 2 arguments.
     */
    public static interface Function2<A,B,R> {
        public R apply(A a, B b) throws Throwable;
    }

    /**
     * A Function with 3 arguments.
     */
    public static interface Function3<A,B,C,R> {
        public R apply(A a, B b, C c) throws Throwable;
    }

    /**
     * A promise to produce a result of type <code>A</code>.
     */
    public static class Promise<A> {

        private final scala.concurrent.Future<A> promise;

        /**
         * Create a new promise wrapping the given Scala promise
         *
         * @param promise The scala promise to wrap
         */
        public Promise( scala.concurrent.Future<A> promise) {
            this.promise = promise;
        }

        /*
         * reset underlying shared actors
         * useful for mainly in tests
         */
        public static void resetActors() {
            actors = null;
        }

        /**
         * Combine the given promises into a single promise for the list of results.
         *
         * @param promises The promises to combine
         * @return A single promise whose methods act on the list of redeemed promises
         */
        public static <A> Promise<List<A>> waitAll(Promise<? extends A>... promises){
            return new Promise<List<A>>(play.core.j.JavaPromise.<A>sequence(java.util.Arrays.asList(promises)));
        }

        /**
         * Create a Promise that is redeemed after a timeout.
         *
         * @param message The message to use to redeem the Promise.
         * @param delay The delay (expressed with the corresponding unit).
         * @param unit The Unit.
         */
        public static <A> Promise<A> timeout(A message, Long delay, java.util.concurrent.TimeUnit unit) {
            return new Promise(play.core.j.JavaPromise.timeout(message, delay, unit));
        }

        /**
         * Create a Promise timer that is throwing a TimeoutException after the default timeout duration expires.
         *
         * The returned Promise is usually combined with other Promises.
         *
         * @return a promise without a real value 
         *
         */
        public static Promise<scala.Unit> timeout() throws TimeoutException {
            return new Promise(play.core.j.JavaPromise.timeout());
        }

        /**
         * Create a Promise that is redeemed after a timeout.
         *
         * @param message The message to use to redeem the Promise.
         * @param delay The delay expressed in Milliseconds.
         */
        public static <A> Promise<A> timeout(A message, Long delay) {
            return timeout(message, delay, java.util.concurrent.TimeUnit.MILLISECONDS);
        }

        /**
         * Combine the given promises into a single promise for the list of results.
         *
         * @param promises The promises to combine
         * @return A single promise whose methods act on the list of redeemed promises
         */
        public static <A> Promise<List<A>> waitAll(Iterable<Promise<? extends A>> promises){
            ArrayList<Promise<? extends A>> ps = new ArrayList<Promise<? extends A>>();
            for(Promise<? extends A> p : promises){
                ps.add(p);
            }
            return new Promise<List<A>>(play.core.j.JavaPromise.<A>sequence(ps));
        }

        /**
         * Create a new pure promise, that is, a promise with a constant value from the start.
         *
         * @param a the value for the promise
         */
        public static <A> Promise<A> pure(final A a) {
            return new Promise<A>(play.core.j.JavaPromise.<A>pure(a));
        }

        /**
         * Create a new promise throwing an exception.
         * @param throwable Value to throw
         */<commit_msg>deprecated the waitAll API<commit_after>package play.libs;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import play.core.Invoker;

/**
 * Defines a set of functional programming style helpers.
 */
public class F {

    /**
     * A Callback with no arguments.
     */
    public static interface Callback0 {
        public void invoke() throws Throwable;
    }

    /**
     * A Callback with a single argument.
     */
    public static interface Callback<A> {
        public void invoke(A a) throws Throwable;
    }

    /**
     * A Callback with 2 arguments.
     */
    public static interface Callback2<A,B> {
        public void invoke(A a, B b) throws Throwable;
    }

    /**
     * A Callback with 3 arguments.
     */
    public static interface Callback3<A,B,C> {
        public void invoke(A a, B b, C c) throws Throwable;
    }

    /**
     * A Function with no arguments.
     */
    public static interface Function0<R> {
        public R apply() throws Throwable;
    }

    /**
     * A Function with a single argument.
     */
    public static interface Function<A,R> {
        public R apply(A a) throws Throwable;
    }

    /**
     * A Function with 2 arguments.
     */
    public static interface Function2<A,B,R> {
        public R apply(A a, B b) throws Throwable;
    }

    /**
     * A Function with 3 arguments.
     */
    public static interface Function3<A,B,C,R> {
        public R apply(A a, B b, C c) throws Throwable;
    }

    /**
     * A promise to produce a result of type <code>A</code>.
     */
    public static class Promise<A> {

        private final scala.concurrent.Future<A> promise;

        /**
         * Create a new promise wrapping the given Scala promise
         *
         * @param promise The scala promise to wrap
         */
        public Promise( scala.concurrent.Future<A> promise) {
            this.promise = promise;
        }

        /*
         * reset underlying shared actors
         * useful for mainly in tests
         */
        public static void resetActors() {
            actors = null;
        }

        /**
         * Combine the given promises into a single promise for the list of results.
         *
         * @param promises The promises to combine
         * @return A single promise whose methods act on the list of redeemed promises
         */
        public static <A> Promise<List<A>> sequence(Promise<? extends A>... promises){
            return new Promise<List<A>>(play.core.j.JavaPromise.<A>sequence(java.util.Arrays.asList(promises)));
        }

        /**
         * Combine the given promises into a single promise for the list of results.
         *
         * @param promises The promises to combine
         * @return A single promise whose methods act on the list of redeemed promises
         * @deprecated As of release 2.1, replaced by {@link #sequence}
         */

        @Deprecated public static <A> Promise<List<A>> waitAll(Promise<? extends A>... promises){
            return sequence(promises);
        }

        /**
         * Create a Promise that is redeemed after a timeout.
         *
         * @param message The message to use to redeem the Promise.
         * @param delay The delay (expressed with the corresponding unit).
         * @param unit The Unit.
         */
        public static <A> Promise<A> timeout(A message, Long delay, java.util.concurrent.TimeUnit unit) {
            return new Promise(play.core.j.JavaPromise.timeout(message, delay, unit));
        }

        /**
         * Create a Promise timer that is throwing a TimeoutException after the default timeout duration expires.
         *
         * The returned Promise is usually combined with other Promises.
         *
         * @return a promise without a real value 
         *
         */
        public static Promise<scala.Unit> timeout() throws TimeoutException {
            return new Promise(play.core.j.JavaPromise.timeout());
        }

        /**
         * Create a Promise that is redeemed after a timeout.
         *
         * @param message The message to use to redeem the Promise.
         * @param delay The delay expressed in Milliseconds.
         */
        public static <A> Promise<A> timeout(A message, Long delay) {
            return timeout(message, delay, java.util.concurrent.TimeUnit.MILLISECONDS);
        }

        /**
         * Combine the given promises into a single promise for the list of results.
         *
         * @param promises The promises to combine
         * @return A single promise whose methods act on the list of redeemed promises
         */
        public static <A> Promise<List<A>> sequence(Iterable<Promise<? extends A>> promises){
            ArrayList<Promise<? extends A>> ps = new ArrayList<Promise<? extends A>>();
            for(Promise<? extends A> p : promises){
                ps.add(p);
            }
            return new Promise<List<A>>(play.core.j.JavaPromise.<A>sequence(ps));
        }


        /**
         * Combine the given promises into a single promise for the list of results.
         *
         * @param promises The promises to combine
         * @return A single promise whose methods act on the list of redeemed promises
         * @deprecated As of release 2.1, replaced by {@link #sequence}
         */
        @Deprecated public static <A> Promise<List<A>> waitAll(Iterable<Promise<? extends A>> promises){
            return sequence(promises);
        }

        /**
         * Create a new pure promise, that is, a promise with a constant value from the start.
         *
         * @param a the value for the promise
         */
        public static <A> Promise<A> pure(final A a) {
            return new Promise<A>(play.core.j.JavaPromise.<A>pure(a));
        }

        /**
         * Create a new promise throwing an exception.
         * @param throwable Value to throw
         */
{'fraction_non_alphanumeric': 0.0927158273381295, 'fraction_numerical': 0.002158273381294964, 'mean_word_length': 1.9350752177355504, 'pattern_counts': {'":': 0, '<': 94, '<?xml version=': 0, '>': 94, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4902790', 'n_tokens_mistral': 2947, 'n_tokens_neox': 2871, 'n_words': 1073}