text:
package org.lambda4j.predicate;

import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.DoubleToIntFunction;
import java.util.function.IntPredicate;
import java.util.function.IntUnaryOperator;
import java.util.function.LongToIntFunction;
import java.util.function.ToIntFunction;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.lambda4j.Lambda;
import org.lambda4j.consumer.BooleanConsumer;
import org.lambda4j.consumer.IntConsumer2;
import org.lambda4j.function.BooleanFunction;
import org.lambda4j.function.IntFunction2;
import org.lambda4j.function.conversion.BooleanToByteFunction;
import org.lambda4j.function.conversion.BooleanToCharFunction;
import org.lambda4j.function.conversion.BooleanToDoubleFunction;
import org.lambda4j.function.conversion.BooleanToFloatFunction;
import org.lambda4j.function.conversion.BooleanToIntFunction;
import org.lambda4j.function.conversion.BooleanToLongFunction;
import org.lambda4j.function.conversion.BooleanToShortFunction;
import org.lambda4j.function.conversion.ByteToIntFunction;
import org.lambda4j.function.conversion.CharToIntFunction;
import org.lambda4j.function.conversion.FloatToIntFunction;
import org.lambda4j.function.conversion.IntToByteFunction;
import org.lambda4j.function.conversion.IntToCharFunction;
import org.lambda4j.function.conversion.IntToDoubleFunction2;
import org.lambda4j.function.conversion.IntToFloatFunction;
import org.lambda4j.function.conversion.IntToLongFunction2;
import org.lambda4j.function.conversion.IntToShortFunction;
import org.lambda4j.function.conversion.ShortToIntFunction;
import org.lambda4j.operator.unary.BooleanUnaryOperator;
import org.lambda4j.operator.unary.IntUnaryOperator2;

/**
 * Represents an predicate (boolean-valued function) of one {@code int}-valued input argument. This is a primitive
 * specialization of {@link Predicate2}.
 *

 * This is a {@link FunctionalInterface} whose functional method is {@link #test(int)}.
 *
 * @apiNote This is a JDK lambda.
 * @see Predicate2
 */
@SuppressWarnings("unused")
@FunctionalInterface
public interface IntPredicate2 extends Lambda, IntPredicate {

    /**
     * Constructs a {@link IntPredicate2} based on a lambda expression or a method reference. Thereby the given lambda
     * expression or method reference is returned on an as-is basis to implicitly transform it to the desired type. With
     * this method, it is possible to ensure that correct type is used from lambda expression or method reference.
     *
     * @param expression A lambda expression or (typically) a method reference, e.g. {@code this::method}
     * @return A {@code IntPredicate2} from given lambda expression or method reference.
     * @implNote This implementation allows the given argument to be {@code null}, but only if {@code null} given,
     * {@code null} will be returned.
     * @see Lambda
     * Expression
     * @see Method Reference
     */
    @CheckForNull
    @Nullable
    static IntPredicate2 of(@Nullable IntPredicate2 expression) {
        return expression;
    }

    /**
     * Calls the given {@link IntPredicate} with the given argument and returns its result.
     *
     * @param predicate The predicate to be called
     * @param value The argument to the predicate
     * @return The result from the given {@code IntPredicate2}.
     * @throws NullPointerException If given argument is {@code null}
     */
    static boolean call(@Nonnull IntPredicate predicate, int value) {
        Objects.requireNonNull(predicate);
        return predicate.test(value);
    }

    /**
     * Creates a {@link IntPredicate2} which always returns a given value.
     *
     * @param ret The return value for the constant
     * @return A {@code IntPredicate2} which always returns a given value.
     */
    @Nonnull
    static IntPredicate2 constant(boolean ret) {
        return value -> ret;
    }

    /**
     * Returns a {@link IntPredicate2} that always returns {@code true}.
     *
     * @return A {@link IntPredicate2} that always returns {@code true}.
     * @see #alwaysFalse()
     */
    @Nonnull
    static IntPredicate2 alwaysTrue() {
        return value -> true;
    }

    /**
     * Returns a {@link IntPredicate2} that always returns {@code false}.
     *
     * @return A {@link IntPredicate2} that always returns {@code false}.
     * @see #alwaysTrue()
     */
    @Nonnull
    static IntPredicate2 alwaysFalse() {
        return value -> false;
    }

    /**
     * Returns a {@link IntPredicate2} that tests if the given argument is equal to the one of this predicate.
     *
     * @param target The reference with which to compare for equality, which may be {@code null}
     * @return A {@code IntPredicate2} that tests if the given argument is equal to the one of this predicate.
     * @implNote This implementation checks equality according to {@link Objects#equals(Object)} operation for {@link
     * Object} references and {@code value == target} operation for primitive values.
     */
    @Nonnull
    static IntPredicate2 isEqual(int target) {
        return value -> value == target;
    }

    /**
     * Applies this predicate to the given argument.
     *
     * @param value The argument to the predicate
     * @return The return value from the predicate, which is its result.
     */
    @Override
    boolean test(int value);

    /**
     * Returns the number of arguments for this predicate.
     *
     * @return The number of arguments for this predicate.
     * @implSpec The default implementation always returns {@code 1}.
     */
    @Nonnegative
    default int arity() {
        return 1;
    }

    /**
     * Returns a composed {@link Predicate2} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation.
     *
     * @param  The type of the argument to the given function, and of composed predicate
     * @param before The function to apply before this predicate is applied
     * @return A composed {@code Predicate2} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to handle every type.
     */
    @Nonnull
    default  Predicate2 compose(@Nonnull ToIntFunction<? super A> before) {
        Objects.requireNonNull(before);
        return a -> test(before.applyAsInt(a));
    }

    /**
     * Returns a composed {@link BooleanUnaryOperator} that first applies the {@code before} function to its input, and
     * then applies this predicate to the result. If evaluation of either operation throws an exception, it is relayed
     * to the caller of the composed operation. This method is just convenience, to provide the ability to execute an
     * operation which accepts {@code boolean} input, before this primitive predicate is executed.
     *
     * @param before The function to apply before this predicate is applied
     * @return A composed {@code BooleanUnaryOperator} that first applies the {@code before} function to its input, and
     * then applies this predicate to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to handle primitive values. In this case this is {@code
     * boolean}.
     */
    @Nonnull
    default BooleanUnaryOperator composeFromBoolean(@Nonnull BooleanToIntFunction before) {
        Objects.requireNonNull(before);
        return value -> test(before.applyAsInt(value));
    }

    /**
     * Returns a composed {@link BytePredicate} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to execute an operation
     * which accepts {@code byte} input, before this primitive predicate is executed.
     *
     * @param before The function to apply before this predicate is applied
     * @return A composed {@code BytePredicate} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to handle primitive values. In this case this is {@code
     * byte}.
     */
    @Nonnull
    default BytePredicate composeFromByte(@Nonnull ByteToIntFunction before) {
        Objects.requireNonNull(before);
        return value -> test(before.applyAsInt(value));
    }

    /**
     * Returns a composed {@link CharPredicate} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to execute an operation
     * which accepts {@code char} input, before this primitive predicate is executed.
     *
     * @param before The function to apply before this predicate is applied
     * @return A composed {@code CharPredicate} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to handle primitive values. In this case this is {@code
     * char}.
     */
    @Nonnull
    default CharPredicate composeFromChar(@Nonnull CharToIntFunction before) {
        Objects.requireNonNull(before);
        return value -> test(before.applyAsInt(value));
    }

    /**
     * Returns a composed {@link DoublePredicate2} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to execute an operation
     * which accepts {@code double} input, before this primitive predicate is executed.
     *
     * @param before The function to apply before this predicate is applied
     * @return A composed {@code DoublePredicate2} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to handle primitive values. In this case this is {@code
     * double}.
     */
    @Nonnull
    default DoublePredicate2 composeFromDouble(@Nonnull DoubleToIntFunction before) {
        Objects.requireNonNull(before);
        return value -> test(before.applyAsInt(value));
    }

    /**
     * Returns a composed {@link FloatPredicate} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to execute an operation
     * which accepts {@code float} input, before this primitive predicate is executed.
     *
     * @param before The function to apply before this predicate is applied
     * @return A composed {@code FloatPredicate} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to handle primitive values. In this case this is {@code
     * float}.
     */
    @Nonnull
    default FloatPredicate composeFromFloat(@Nonnull FloatToIntFunction before) {
        Objects.requireNonNull(before);
        return value -> test(before.applyAsInt(value));
    }

    /**
     * Returns a composed {@link IntPredicate2} that first applies the {@code before} operator to its input, and then
     * applies this predicate to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to execute an operation
     * which accepts {@code int} input, before this primitive predicate is executed.
     *
     * @param before The operator to apply before this predicate is applied
     * @return A composed {@code IntPredicate2} that first applies the {@code before} operator to its input, and then
     * applies this predicate to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to handle primitive values. In this case this is {@code
     * int}.
     */
    @Nonnull
    default IntPredicate2 composeFromInt(@Nonnull IntUnaryOperator before) {
        Objects.requireNonNull(before);
        return value -> test(before.applyAsInt(value));
    }

    /**
     * Returns a composed {@link LongPredicate2} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to execute an operation
     * which accepts {@code long} input, before this primitive predicate is executed.
     *
     * @param before The function to apply before this predicate is applied
     * @return A composed {@code LongPredicate2} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to handle primitive values. In this case this is {@code
     * long}.
     */
    @Nonnull
    default LongPredicate2 composeFromLong(@Nonnull LongToIntFunction before) {
        Objects.requireNonNull(before);
        return value -> test(before.applyAsInt(value));
    }

    /**
     * Returns a composed {@link ShortPredicate} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to execute an operation
     * which accepts {@code short} input, before this primitive predicate is executed.
     *
     * @param before The function to apply before this predicate is applied
     * @return A composed {@code ShortPredicate} that first applies the {@code before} function to its input, and then
     * applies this predicate to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to handle primitive values. In this case this is {@code
     * short}.
     */
    @Nonnull
    default ShortPredicate composeFromShort(@Nonnull ShortToIntFunction before) {
        Objects.requireNonNull(before);
        return value -> test(before.applyAsInt(value));
    }

    /**
     * Returns a composed {@link IntFunction2} that first applies this predicate to its input, and then applies the
     * {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation.
     *
     * @param <S> The type of return value from the {@code after} function, and of the composed function
     * @param after The function to apply after this predicate is applied
     * @return A composed {@code IntFunction2} that first applies this predicate to its input, and then applies the
     * {@code after} function to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to return every type.
     */
    @Nonnull
    default <S> IntFunction2<S> andThen(@Nonnull BooleanFunction<? extends S> after) {
        Objects.requireNonNull(after);
        return value -> after.apply(test(value));
    }

    /**
     * Returns a composed {@link IntPredicate2} that first applies this predicate to its input, and then applies the
     * {@code after} operator to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to transform this
     * primitive predicate to an operation returning {@code boolean}.
     *
     * @param after The operator to apply after this predicate is applied
     * @return A composed {@code IntPredicate2} that first applies this predicate to its input, and then applies the
     * {@code after} operator to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to return primitive values. In this case this is {@code
     * boolean}.
     */
    @Nonnull
    default IntPredicate2 andThenToBoolean(@Nonnull BooleanUnaryOperator after) {
        Objects.requireNonNull(after);
        return value -> after.applyAsBoolean(test(value));
    }

    /**
     * Returns a composed {@link IntToByteFunction} that first applies this predicate to its input, and then applies the
     * {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to transform this
     * primitive predicate to an operation returning {@code byte}.
     *
     * @param after The function to apply after this predicate is applied
     * @return A composed {@code IntToByteFunction} that first applies this predicate to its input, and then applies the
     * {@code after} function to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to return primitive values. In this case this is {@code
     * byte}.
     */
    @Nonnull
    default IntToByteFunction andThenToByte(@Nonnull BooleanToByteFunction after) {
        Objects.requireNonNull(after);
        return value -> after.applyAsByte(test(value));
    }

    /**
     * Returns a composed {@link IntToCharFunction} that first applies this predicate to its input, and then applies the
     * {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to transform this
     * primitive predicate to an operation returning {@code char}.
     *
     * @param after The function to apply after this predicate is applied
     * @return A composed {@code IntToCharFunction} that first applies this predicate to its input, and then applies the
     * {@code after} function to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to return primitive values. In this case this is {@code
     * char}.
     */
    @Nonnull
    default IntToCharFunction andThenToChar(@Nonnull BooleanToCharFunction after) {
        Objects.requireNonNull(after);
        return value -> after.applyAsChar(test(value));
    }

    /**
     * Returns a composed {@link IntToDoubleFunction2} that first applies this predicate to its input, and then applies
     * the {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to
     * the caller of the composed operation. This method is just convenience, to provide the ability to transform this
     * primitive predicate to an operation returning {@code double}.
     *
     * @param after The function to apply after this predicate is applied
     * @return A composed {@code IntToDoubleFunction2} that first applies this predicate to its input, and then applies
     * the {@code after} function to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to return primitive values. In this case this is {@code
     * double}.
     */
    @Nonnull
    default IntToDoubleFunction2 andThenToDouble(@Nonnull BooleanToDoubleFunction after) {
        Objects.requireNonNull(after);
        return value -> after.applyAsDouble(test(value));
    }

    /**
     * Returns a composed {@link IntToFloatFunction} that first applies this predicate to its input, and then applies
     * the {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to
     * the caller of the composed operation. This method is just convenience, to provide the ability to transform this
     * primitive predicate to an operation returning {@code float}.
     *
     * @param after The function to apply after this predicate is applied
     * @return A composed {@code IntToFloatFunction} that first applies this predicate to its input, and then applies
     * the {@code after} function to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to return primitive values. In this case this is {@code
     * float}.
     */
    @Nonnull
    default IntToFloatFunction andThenToFloat(@Nonnull BooleanToFloatFunction after) {
        Objects.requireNonNull(after);
        return value -> after.applyAsFloat(test(value));
    }

    /**
     * Returns a composed {@link IntUnaryOperator2} that first applies this predicate to its input, and then applies the
     * {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to the
     * caller of the composed operation. This method is just convenience, to provide the ability to transform this
     * primitive predicate to an operation returning {@code int}.
     *
     * @param after The function to apply after this predicate is applied
     * @return A composed {@code IntUnaryOperator2} that first applies this predicate to its input, and then applies the
     * {@code after} function to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to return primitive values. In this case this is {@code
     * int}.
     */
    @Nonnull
    default IntUnaryOperator2 andThenToInt(@Nonnull BooleanToIntFunction after) {
        Objects.requireNonNull(after);
        return value -> after.applyAsInt(test(value));
    }

    /**
     * Returns a composed {@link IntToLongFunction2} that first applies this predicate to its input, and then applies
     * the {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to
     * the caller of the composed operation. This method is just convenience, to provide the ability to transform this
     * primitive predicate to an operation returning {@code long}.
     *
     * @param after The function to apply after this predicate is applied
     * @return A composed {@code IntToLongFunction2} that first applies this predicate to its input, and then applies
     * the {@code after} function to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to return primitive values. In this case this is {@code
     * long}.
     */
    @Nonnull
    default IntToLongFunction2 andThenToLong(@Nonnull BooleanToLongFunction after) {
        Objects.requireNonNull(after);
        return value -> after.applyAsLong(test(value));
    }

    /**
     * Returns a composed {@link IntToShortFunction} that first applies this predicate to its input, and then applies
     * the {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to
     * the caller of the composed operation. This method is just convenience, to provide the ability to transform this
     * primitive predicate to an operation returning {@code short}.
     *
     * @param after The function to apply after this predicate is applied
     * @return A composed {@code IntToShortFunction} that first applies this predicate to its input, and then applies
     * the {@code after} function to the result.
     * @throws NullPointerException If given argument is {@code null}
     * @implSpec The input argument of this method is able to return primitive values. In this case this is {@code
     * short}.
     */
    @Nonnull
    default IntToShortFunction andThenToShort(@Nonnull BooleanToShortFunction after) {
        Objects.requireNonNull(after);
        return value -> after.applyAsShort(test(value));
    }

    /**
     * Returns a composed {@link IntConsumer2} that fist applies this predicate to its input, and then consumes the
     * result using the given {@link BooleanConsumer}. If evaluation of either operation throws an exception, it is
     * relayed to the caller of the composed operation.
     *
     * @param consumer The operation which consumes the result from this operation
     * @return A composed {@code IntConsumer2} that first applies this predicate to its input, and then consumes the
     * result using the given {@code BooleanConsumer}.
     * @throws NullPointerException If given argument is {@code null}
     */
    @Nonnull
    default IntConsumer2 consume(@Nonnull BooleanConsumer consumer) {
        Objects.requireNonNull(consumer);
        return value -> consumer.accept(test(value));
    }

    /**
     * Returns a {@link IntPredicate2} that represents the logical negation of this one.
     *
     * @return A {@code IntPredicate2} that represents the logical negation of this one.
     */
    @Override
    @Nonnull
    default IntPredicate2 negate() {
        return value -> !test(value);
    }

    /**
     * Returns a composed {@link IntPredicate2} that represents a short-circuiting logical AND of this predicate and
     * another. When evaluating the composed predicate, if this predicate is {@code false}, then the {@code other}
     * predicate is not evaluated.
     *

     * Any exceptions thrown during evaluation of either predicate is relayed to the caller; if evaluation of this
     * {@code IntPredicate2} throws an exception, the {@code other} predicate will not be evaluated.
     *
     * @param other A {@code IntPredicate2} that will be logically-ANDed with this one
     * @return A composed {@code IntPredicate2} that represents the short-circuiting logical AND of this predicate and
     * the {@code other} predicate.
     * @throws NullPointerException If given argument is {@code null}
     * @see #or(IntPredicate)
     * @see #xor(IntPredicate)
     */
    @Override
    @Nonnull
    default IntPredicate2 and(@Nonnull IntPredicate other) {
        Objects.requireNonNull(other);
        return value -> test(value) && other.test(value);
    }

    /**
     * Returns a composed {@link IntPredicate2} that represents a short-circuiting logical OR of this predicate and
     * another. When evaluating the composed predicate, if this predicate is {@code true}, then the {@code other}
     * predicate is not evaluated.
     *

     * Any exceptions thrown during evaluation of either predicate is relayed to the caller; if evaluation of this
     * {@code IntPredicate2} throws an exception, the {@code other} predicate will not be evaluated.
     *
     * @param other A {@code IntPredicate2} that will be logically-ORed with this one
     * @return A composed {@code IntPredicate2} that represents the short-circuiting logical OR of this predicate and
     * the {@code other} predicate.
     * @throws NullPointerException If given argument is {@code null}
     * @see #and(IntPredicate)
     * @see #xor(IntPredicate)
     */
    @Override
    @Nonnull
    default IntPredicate2 or(@Nonnull IntPredicate other) {
        Objects.requireNonNull(other);
        return value -> test(value) || other.test(value);
    }

    /**
     * Returns a composed {@link IntPredicate2} that represents a short-circuiting logical XOR of this predicate and
     * another. Any exceptions thrown during evaluation of either predicate is relayed to the caller; if evaluation of
     * this {@code IntPredicate2} throws an exception, the {@code other} predicate will not be evaluated.
     *
     * @param other A {@code IntPredicate2} that will be logically-XORed with this one
     * @return A composed {@code IntPredicate2} that represents the short-circuiting logical XOR of this predicate and
     * the {@code other} predicate.
     * @throws NullPointerException If given argument is {@code null}
     * @see #and(IntPredicate)
     * @see #or(IntPredicate)
     */
    @Nonnull
    default IntPredicate2 xor(@Nonnull IntPredicate other) {
        Objects.requireNonNull(other);
        return value -> test(value) ^ other.test(value);
    }

    /**
     * Returns a reversed version of this predicate. This may be useful in recursive context.
     *
     * @return A reversed version of this predicate.
     */
    @Nonnull
    default IntPredicate2 reversed() {
        return this;
    }

    /**
     * Returns a memoized (caching) version of this {@link IntPredicate2}. Whenever it is called, the mapping between
     * the input parameter and the return value is preserved in a cache, making subsequent calls returning the memoized
     * value instead of computing the return value again.
     *

     * Unless the predicate and therefore the used cache will be garbage-collected, it will keep all memoized values
     * forever.
     *
     * @return A memoized (caching) version of this {@code IntPredicate2}.
     * @implSpec This implementation does not allow the input parameter or return value to be {@code null} for the
     * resulting memoized predicate, as the cache used internally does not permit {@code null} keys or values.
     * @implNote The returned memoized predicate can be safely used concurrently from multiple threads which makes it
     * thread-safe.
     */
    @Nonnull
    default IntPredicate2 memoized() {
        if (isMemoized()) {
            return this;
        } else {
            Map<Integer, Boolean> cache = new ConcurrentHashMap<>();
            return (IntPredicate2 & Memoized) value -> {
                return cache.computeIfAbsent(value, this::test);
            };
        }
    }

    /**
     * Returns a composed {@link Predicate2} which represents this {@link IntPredicate2}. Thereby the primitive input
     * argument for this predicate is autoboxed. This method provides the possibility to use this {@code IntPredicate2}
     * with methods provided by the {@code JDK}.
     *
     * @return A composed {@code Predicate2} which represents this {@code IntPredicate2}.
     */
    @Nonnull
    default Predicate2<Integer> boxed() {
        return this::test;
    }
}


text:
default_target: all
.PHONY : default_target

#=============================================================================
# Special targets provided by cmake.

# Disable implicit rules so canonical targets will work.
.SUFFIXES:

# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =

.SUFFIXES: .hpux_make_needs_suffix_list

# Suppress display of executed commands.
$(VERBOSE).SILENT:

# A target that is always out of date.
cmake_force:
.PHONY : cmake_force

#=============================================================================
# Set environment variables for the build.

# The shell in which to execute make rules.
SHELL = /bin/sh

# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake

# The command to remove a file.
RM = /usr/bin/cmake -E remove -f

# Escaping for special characters.
EQUALS = =

# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/rex/Desktop/work/linux/algo/DTW-approx

# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /media/sf_work/linux/algo/DTW-approx

#=============================================================================
# Targets provided globally by CMake.

# Special rule for the target edit_cache
edit_cache:
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..."
	/usr/bin/cmake -i .
.PHONY : edit_cache

# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast

# Special rule for the target rebuild_cache
rebuild_cache:
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
	/usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache

# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast

# The main all target
all: cmake_check_build_system
	$(CMAKE_COMMAND) -E cmake_progress_start /media/sf_work/linux/algo/DTW-approx/CMakeFiles /media/sf_work/linux/algo/DTW-approx/CMakeFiles/progress.marks
	$(MAKE) -f CMakeFiles/Makefile2 all
	$(CMAKE_COMMAND) -E cmake_progress_start /media/sf_work/linux/algo/DTW-approx/CMakeFiles 0
.PHONY : all

# The main clean target
clean:
	$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean

# The main clean target
clean/fast: clean
.PHONY : clean/fast

# Prepare targets for installation.
preinstall: all
	$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall

# Prepare targets for installation.
preinstall/fast:
	$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast

# clear depends
depend:
	$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend

#=============================================================================
# Target rules for targets named Frechet

# Build rule for target.
Frechet: cmake_check_build_system
	$(MAKE) -f CMakeFiles/Makefile2 Frechet
.PHONY : Frechet

# fast build rule for target.
Frechet/fast:
	$(MAKE) -f CMakeFiles/Frechet.dir/build.make CMakeFiles/Frechet.dir/build
.PHONY : Frechet/fast

#=============================================================================
# Target rules for targets named WSPD

# Build rule for target.
WSPD: cmake_check_build_system
	$(MAKE) -f CMakeFiles/Makefile2 WSPD
.PHONY : WSPD

# fast build rule for target.
WSPD/fast:
	$(MAKE) -f CMakeFiles/WSPD.dir/build.make CMakeFiles/WSPD.dir/build
.PHONY : WSPD/fast

#=============================================================================
# Target rules for targets named executable

# Build rule for target.
executable: cmake_check_build_system
	$(MAKE) -f CMakeFiles/Makefile2 executable
.PHONY : executable

# fast build rule for target.
executable/fast:
	$(MAKE) -f CMakeFiles/executable.dir/build.make CMakeFiles/executable.dir/build
.PHONY : executable/fast

#=============================================================================
# Target rules for targets named gen_tests

# Build rule for target.
gen_tests: cmake_check_build_system
	$(MAKE) -f CMakeFiles/Makefile2 gen_tests
.PHONY : gen_tests

# fast build rule for target.
gen_tests/fast:
	$(MAKE) -f CMakeFiles/gen_tests.dir/build.make CMakeFiles/gen_tests.dir/build
.PHONY : gen_tests/fast

FrechetDecider.o: FrechetDecider.cpp.o
.PHONY : FrechetDecider.o

# target to build an object file
FrechetDecider.cpp.o:
	$(MAKE) -f CMakeFiles/Frechet.dir/build.make CMakeFiles/Frechet.dir/FrechetDecider.cpp.o
.PHONY : FrechetDecider.cpp.o

FrechetDecider.i: FrechetDecider.cpp.i
.PHONY : FrechetDecider.i

# target to preprocess a source file
FrechetDecider.cpp.i:
	$(MAKE) -f CMakeFiles/Frechet.dir/build.make CMakeFiles/Frechet.dir/FrechetDecider.cpp.i
.PHONY : FrechetDecider.cpp.i

FrechetDecider.s: FrechetDecider.cpp.s
.PHONY : FrechetDecider.s

# target to generate assembly for a file
FrechetDecider.cpp.s:
	$(MAKE) -f CMakeFiles/Frechet.dir/build.make CMakeFiles/Frechet.dir/FrechetDecider.cpp.s
.PHONY : FrechetDecider.cpp.s

QuadTree.o: QuadTree.cpp.o
.PHONY : QuadTree.o

# target to build an object file
QuadTree.cpp.o:
	$(MAKE) -f CMakeFiles/WSPD.dir/build.make CMakeFiles/WSPD.dir/QuadTree.cpp.o
.PHONY : QuadTree.cpp.o

QuadTree.i: QuadTree.cpp.i
.PHONY : QuadTree.i

# target to preprocess a source file
QuadTree.cpp.i:
	$(MAKE) -f CMakeFiles/WSPD.dir/build.make CMakeFiles/WSPD.dir/QuadTree.cpp.i
.PHONY : QuadTree.cpp.i

QuadTree.s: QuadTree.cpp.s
.PHONY : QuadTree.s

# target to generate assembly for a file
QuadTree.cpp.s:
	$(MAKE) -f CMakeFiles/WSPD.dir/build.make CMakeFiles/WSPD.dir/QuadTree.cpp.s
.PHONY : QuadTree.cpp.s

QuadTreeTwoClasses.o: QuadTreeTwoClasses.cpp.o
.PHONY : QuadTreeTwoClasses.o

# target to build an object file
QuadTreeTwoClasses.cpp.o:
	$(MAKE) -f CMakeFiles/WSPD.dir/build.make CMakeFiles/WSPD.dir/QuadTreeTwoClasses.cpp.o
.PHONY : QuadTreeTwoClasses.cpp.o

QuadTreeTwoClasses.i: QuadTreeTwoClasses.cpp.i
.PHONY : QuadTreeTwoClasses.i

# target to preprocess a source file
QuadTreeTwoClasses.cpp.i:
	$(MAKE) -f CMakeFiles/WSPD.dir/build.make CMakeFiles/WSPD.dir/QuadTreeTwoClasses.cpp.i
.PHONY : QuadTreeTwoClasses.cpp.i

QuadTreeTwoClasses.s: QuadTreeTwoClasses.cpp.s
.PHONY : QuadTreeTwoClasses.s

# target to generate assembly for a file
QuadTreeTwoClasses.cpp.s:
	$(MAKE) -f CMakeFiles/WSPD.dir/build.make CMakeFiles/WSPD.dir/QuadTreeTwoClasses.cpp.s
.PHONY : QuadTreeTwoClasses.cpp.s

Sampling.o: Sampling.cpp.o
.PHONY : Sampling.o

# target to build an object file
Sampling.cpp.o:
	$(MAKE) -f CMakeFiles/executable.dir/build.make CMakeFiles/executable.dir/Sampling.cpp.o
.PHONY : Sampling.cpp.o

Sampling.i: Sampling.cpp.i
.PHONY : Sampling.i

# target to preprocess a source file
Sampling.cpp.i:
	$(MAKE) -f CMakeFiles/executable.dir/build.make CMakeFiles/executable.dir/Sampling.cpp.i
.PHONY : Sampling.cpp.i

Sampling.s: Sampling.cpp.s
.PHONY : Sampling.s

# target to generate assembly for a file
Sampling.cpp.s:
	$(MAKE) -f CMakeFiles/executable.dir/build.make CMakeFiles/executable.dir/Sampling.cpp.s
.PHONY : Sampling.cpp.s

WSPD.o: WSPD.cpp.o
.PHONY : WSPD.o

# target to build an object file
WSPD.cpp.o:
	$(MAKE) -f CMakeFiles/WSPD.dir/build.make CMakeFiles/WSPD.dir/WSPD.cpp.o
.PHONY : WSPD.cpp.o

WSPD.i: WSPD.cpp.i
.PHONY : WSPD.i

# target to preprocess a source file
WSPD.cpp.i:
	$(MAKE) -f CMakeFiles/WSPD.dir/build.make CMakeFiles/WSPD.dir/WSPD.cpp.i
.PHONY : WSPD.cpp.i

WSPD.s: WSPD.cpp.s
.PHONY : WSPD.s

# target to generate assembly for a file
WSPD.cpp.s:
	$(MAKE) -f CMakeFiles/WSPD.dir/build.make CMakeFiles/WSPD.dir/WSPD.cpp.s
.PHONY : WSPD.cpp.s

gen_tests.o: gen_tests.cpp.o
.PHONY : gen_tests.o

# target to build an object file
gen_tests.cpp.o:
	$(MAKE) -f CMakeFiles/gen_tests.dir/build.make CMakeFiles/gen_tests.dir/gen_tests.cpp.o
.PHONY : gen_tests.cpp.o

gen_tests.i: gen_tests.cpp.i
.PHONY : gen_tests.i

# target to preprocess a source file
gen_tests.cpp.i:
	$(MAKE) -f CMakeFiles/gen_tests.dir/build.make CMakeFiles/gen_tests.dir/gen_tests.cpp.i
.PHONY : gen_tests.cpp.i

gen_tests.s: gen_tests.cpp.s
.PHONY : gen_tests.s

# target to generate assembly for a file
gen_tests.cpp.s:
	$(MAKE) -f CMakeFiles/gen_tests.dir/build.make CMakeFiles/gen_tests.dir/gen_tests.cpp.s
.PHONY : gen_tests.cpp.s

main.o: main.cpp.o
.PHONY : main.o

# target to build an object file
main.cpp.o:
	$(MAKE) -f CMakeFiles/executable.dir/build.make CMakeFiles/executable.dir/main.cpp.o
.PHONY : main.cpp.o

main.i: main.cpp.i
.PHONY : main.i

# target to preprocess a source file
main.cpp.i:
	$(MAKE) -f CMakeFiles/executable.dir/build.make CMakeFiles/executable.dir/main.cpp.i
.PHONY : main.cpp.i

main.s: main.cpp.s
.PHONY : main.s

# target to generate assembly for a file
main.cpp.s:
	$(MAKE) -f CMakeFiles/executable.dir/build.make CMakeFiles/executable.dir/main.cpp.s
.PHONY : main.cpp.s

# Help Target
help:
	@echo "The following are some of the valid targets for this Makefile:"
	@echo "... all (the default if no target is provided)"
	@echo "... clean"
	@echo "... depend"
	@echo "... Frechet"
	@echo "... WSPD"
	@echo "... edit_cache"
	@echo "... executable"
	@echo "... gen_tests"
	@echo "... rebuild_cache"
	@echo "... FrechetDecider.o"
	@echo "... FrechetDecider.i"
	@echo "... FrechetDecider.s"
	@echo "... QuadTree.o"
	@echo "... QuadTree.i"
	@echo "... QuadTree.s"
	@echo "... QuadTreeTwoClasses.o"
	@echo "... QuadTreeTwoClasses.i"
	@echo "... QuadTreeTwoClasses.s"
	@echo "... Sampling.o"
	@echo "... Sampling.i"
	@echo "... Sampling.s"
	@echo "... WSPD.o"
	@echo "... WSPD.i"
	@echo "... WSPD.s"
	@echo "... gen_tests.o"
	@echo "... gen_tests.i"
	@echo "... gen_tests.s"
	@echo "... main.o"
	@echo "... main.i"
	@echo "... main.s"
.PHONY : help

#=============================================================================
# Special targets to cleanup operation of make.

# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
	$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system

redpajama_set_name: RedPajamaGithub


text:
package core.framework.search;

/**
 * @author neo
 */
public interface ElasticSearch {
    // create index or update mappings
    void putIndex(String index, String source);

    void putIndexTemplate(String name, String source);

    void closeIndex(String index);

    void deleteIndex(String index);

    ClusterStateResponse state();

    void refreshIndex(String index);
}


text:
<?php

namespace Oro\Bundle\QueryDesignerBundle\Form\Type;

use Oro\Bundle\EntityBundle\Form\Type\EntityFieldSelectType;
use Oro\Bundle\QueryDesignerBundle\QueryDesigner\Manager;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class GroupingType extends AbstractType
{
    const NAME = 'oro_query_designer_grouping';

    /** @var Manager */
    protected $manager;

    /**
     * @param Manager $manager
     */
    public function __construct(Manager $manager)
    {
        $this->manager = $manager;
    }

    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $options = [
            'required'            => true,
            'page_component_name' => 'grouping-field-choice',
        ];

        $metadata = $this->manager->getMetadataForGrouping();
        if (isset($metadata['include'])) {
            $options['include_fields'] = $metadata['include'];
        }
        if (isset($metadata['exclude'])) {
            $options['exclude_fields'] = $metadata['exclude'];
        }

        $builder
            ->add('columnNames', FieldChoiceType::class, $options);
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            array(
                'entity'             => null,
                'data_class'         => 'Oro\Bundle\QueryDesignerBundle\Model\Grouping',
                'csrf_token_id'      => 'query_designer_grouping',
                'column_choice_type' => EntityFieldSelectType::class
            )
        );
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return $this->getBlockPrefix();
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix()
    {
        return self::NAME;
    }
}


text:
package org.gradle.api.internal.tasks;

import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import groovy.lang.Closure;
import org.gradle.api.Action;
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.NamedDomainObjectCollectionSchema;
import org.gradle.api.Task;
import org.gradle.api.UnknownTaskException;
import org.gradle.api.internal.CollectionCallbackActionDecorator;
import org.gradle.api.internal.DefaultNamedDomainObjectSet;
import org.gradle.api.internal.MutationGuard;
import org.gradle.api.internal.collections.CollectionFilter;
import org.gradle.api.internal.plugins.DslObject;
import org.gradle.api.internal.project.ProjectInternal;
import org.gradle.api.internal.provider.ProviderInternal;
import org.gradle.api.reflect.TypeOf;
import org.gradle.api.specs.Spec;
import org.gradle.api.specs.Specs;
import org.gradle.api.tasks.TaskCollection;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.internal.Cast;
import org.gradle.internal.reflect.Instantiator;
import org.gradle.model.internal.core.ModelPath;

import java.util.Map;

import static org.gradle.api.reflect.TypeOf.typeOf;

public class DefaultTaskCollection<T extends Task> extends DefaultNamedDomainObjectSet<T> implements TaskCollection<T> {
    private static final Task.Namer NAMER = new Task.Namer();

    protected final ProjectInternal project;

    private final MutationGuard parentMutationGuard;

    public DefaultTaskCollection(Class<T> type, Instantiator instantiator, ProjectInternal project, MutationGuard parentMutationGuard, CollectionCallbackActionDecorator decorator) {
        super(type, instantiator, NAMER, decorator);
        this.project = project;
        this.parentMutationGuard = parentMutationGuard;
    }

    public DefaultTaskCollection(DefaultTaskCollection<? super T> collection, CollectionFilter<T> filter, Instantiator instantiator, ProjectInternal project, MutationGuard parentMutationGuard) {
        super(collection, filter, instantiator, NAMER);
        this.project = project;
        this.parentMutationGuard = parentMutationGuard;
    }

    @Override
    protected <S extends T> DefaultTaskCollection<S> filtered(CollectionFilter<S> filter) {
        return Cast.uncheckedNonnullCast(getInstantiator().newInstance(DefaultTaskCollection.class, this, filter, getInstantiator(), project, parentMutationGuard));
    }

    @Override
    public <S extends T> TaskCollection<S> withType(Class<S> type) {
        return filtered(createFilter(type));
    }

    @Override
    public TaskCollection<T> matching(Spec<? super T> spec) {
        return filtered(createFilter(spec));
    }

    @Override
    public TaskCollection<T> matching(Closure spec) {
        return matching(Specs.<T>convertClosureToSpec(spec));
    }

    @Override
    public Action<? super T> whenTaskAdded(Action<? super T> action) {
        return whenObjectAdded(action);
    }

    @Override
    public void whenTaskAdded(Closure closure) {
        whenObjectAdded(closure);
    }

    @Override
    public String getTypeDisplayName() {
        return "task";
    }

    @Override
    protected UnknownTaskException createNotFoundException(String name) {
        return new UnknownTaskException(String.format("Task with name '%s' not found in %s.", name, project));
    }

    @Override
    protected InvalidUserDataException createWrongTypeException(String name, Class expected, Class actual) {
        return new InvalidUserDataException(String.format("The task '%s' (%s) is not a subclass of the given type (%s).", name, actual.getCanonicalName(), expected.getCanonicalName()));
    }

    @Override
    public TaskProvider<T> named(String name) throws UnknownTaskException {
        return (TaskProvider<T>) super.named(name);
    }

    @Override
    public TaskProvider<T> named(String name, Action<? super T> configurationAction) throws UnknownTaskException {
        return (TaskProvider<T>) super.named(name, configurationAction);
    }

    @Override
    public <S extends T> TaskProvider<S> named(String name, Class<S> type) throws UnknownTaskException {
        return (TaskProvider<S>) super.named(name, type);
    }

    @Override
    public <S extends T> TaskProvider<S> named(String name, Class<S> type, Action<? super S> configurationAction) throws UnknownTaskException {
        return (TaskProvider<S>) super.named(name, type, configurationAction);
    }

    @Override
    protected TaskProvider<? extends T> createExistingProvider(String name, T object) {
        // TODO: This isn't quite right. We're leaking the _implementation_ type here.  But for tasks, this is usually right.
        return Cast.uncheckedCast(getInstantiator().newInstance(ExistingTaskProvider.class, this, object.getName(), new DslObject(object).getDeclaredType()));
    }

    @Override
    protected <I extends T> Action<? super I> withMutationDisabled(Action<? super I> action) {
        return parentMutationGuard.withMutationDisabled(super.withMutationDisabled(action));
    }

    @Override
    protected boolean hasWithName(String name) {
        return (project.getModelRegistry() != null && project.getModelRegistry().state(ModelPath.path("tasks." + name)) != null) || super.hasWithName(name);
    }

    @Override
    public NamedDomainObjectCollectionSchema getCollectionSchema() {
        return new NamedDomainObjectCollectionSchema() {
            @Override
            public Iterable<? extends NamedDomainObjectSchema> getElements() {
                return Iterables.concat(
                    Iterables.transform(index.asMap().entrySet(), new Function<Map.Entry<String, T>, NamedDomainObjectSchema>() {
                        @Override
                        public NamedDomainObjectSchema apply(final Map.Entry<String, T> e) {
                            return new NamedDomainObjectSchema() {
                                @Override
                                public String getName() {
                                    return e.getKey();
                                }

                                @Override
                                public TypeOf<?> getPublicType() {
                                    // TODO: This returns the wrong public type for domain objects
                                    // created with the eager APIs or added directly to the container.
                                    // This can leak internal types.
                                    // We do not currently keep track of the type used when creating
                                    // a domain object (via create) or the type of the container when
                                    // a domain object is added directly (via add).
                                    return new DslObject(e.getValue()).getPublicType();
                                }
                            };
                        }
                    }),
                    Iterables.transform(index.getPendingAsMap().entrySet(), new Function<Map.Entry<String, ProviderInternal<? extends T>>, NamedDomainObjectSchema>() {
                        @Override
                        public NamedDomainObjectSchema apply(final Map.Entry<String, ProviderInternal<? extends T>> e) {
                            return new NamedDomainObjectSchema() {
                                @Override
                                public String getName() {
                                    return e.getKey();
                                }

                                @Override
                                public TypeOf<?> getPublicType() {
                                    return typeOf(e.getValue().getType());
                                }
                            };
                        }
                    })
                );
            }
        };
    }

    public Action<? super T> whenObjectRemovedInternal(Action<? super T> action) {
        return super.whenObjectRemoved(action);
    }

    // Cannot be private due to reflective instantiation
    public class ExistingTaskProvider<I extends T> extends ExistingNamedDomainObjectProvider<I> implements TaskProvider<I> {
        public ExistingTaskProvider(String name, Class<I> type) {
            super(name, type);
        }

        @Override
        public ValueProducer getProducer() {
            return ValueProducer.taskState(get());
        }
    }
}


text:
<?php
namespace SvyaznoyApi\Tests\Library;

use PHPUnit\Framework\TestCase;
use SvyaznoyApi\Library\PaymentType;

class PaymentTypeTest extends TestCase
{

    public function testGetString()
    {
        $this->assertTrue(PaymentType::getName(PaymentType::TYPE_CARD) == PaymentType::$typeStrings[PaymentType::TYPE_CARD]);
        $this->assertTrue(PaymentType::getName('NonExistentType') === PaymentType::UNKNOWN_TYPE_STRING);
    }

}


text:
module com.example.foo {
	requires com.example.foo.http;
	requires java.logging;
	requires transitive com.example.foo.network;
	exports com.example.foo.bar;
	exports com.example.foo.internal to com.example.foo.probe;
	opens com.example.foo.quux;
	opens com.example.foo.internal to com.example.foo.network,
	com.example.foo.probe;
	uses com.example.foo.spi.Intf;
	provides com.example.foo.spi.Intf with com.example.foo.Impl;
}


text:
<?php

namespace Cms\Mvc\ViewHelper;

/**
 * Helper ACL (uprawnień)
 */
class AclAllowed extends \Mmi\Mvc\ViewHelper\HelperAbstract
{
    /**
     * Zwraca czy dozwolone na ACL
     * @param array $params
     * @return boolean
     */
    public function aclAllowed(array $params)
    {
        //defaults
        $params['module'] = isset($params['module']) ? $params['module'] : 'mmi';
        $params['controller'] = isset($params['controller']) ? $params['controller'] : 'index';
        $params['action'] = isset($params['action']) ? $params['action'] : 'index';
        //zwrot z ACL
        return $this->view->getAcl()->isAllowed($this->view->getAuth()->getRoles(), strtolower($params['module'] . ':' . $params['controller'] . ':' . $params['action']));
    }
}


text:
<?php

namespace Cascade\Tests\Config;

use Cascade\Config\ConfigLoader;
use Cascade\Tests\Fixtures;

/**
 * Class ConfigLoaderTest
 *
 * @author Raphael Antonmattei <rantonmattei@theorchard.com>
 */
class ConfigLoaderTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Loader to test against
     * @var ConfigLoader
     */
    protected $loader = null;

    public function setUp()
    {
        parent::setup();
        $this->loader = new ConfigLoader();
    }

    public function tearDown()
    {
        $this->loader = null;
        parent::tearDown();
    }

    public function testLoader()
    {
        $this->assertInstanceOf(
            'Symfony\Component\Config\Loader\DelegatingLoader',
            $this->loader
        );

        $this->assertInstanceOf(
            'Symfony\Component\Config\Loader\LoaderResolver',
            $this->loader->getResolver()
        );

        $configLoaders = $this->loader->getResolver()->getLoaders();
        $this->assertCount(4, $configLoaders);

        // Checking the order of thr loaders
        $this->assertInstanceOf(
            'Cascade\Config\Loader\PhpArray',
            $configLoaders[0]
        );
        $this->assertInstanceOf(
            'Cascade\Config\Loader\FileLoader\PhpArray',
            $configLoaders[1]
        );
        $this->assertInstanceOf(
            'Cascade\Config\Loader\FileLoader\Json',
            $configLoaders[2]
        );
        $this->assertInstanceOf(
            'Cascade\Config\Loader\FileLoader\Yaml',
            $configLoaders[3]
        );
    }

    public function testLoad()
    {
        $json = Fixtures::getSampleJsonString();
        $this->assertEquals(json_decode($json, true), $this->loader->load($json));
    }
}


text:
namespace globjects
{

template <typename... Arguments> void info(const char* format, Arguments... arguments)
{
    assert(format != nullptr);

    info() << formatString(format, arguments...);
}

template <typename... Arguments> void debug(const char* format, Arguments... arguments)
{
    assert(format != nullptr);

    debug() << formatString(format, arguments...);
}

template <typename... Arguments> void warning(const char* format, Arguments... arguments)
{
    assert(format != nullptr);

    warning() << formatString(format, arguments...);
}

template <typename... Arguments> void critical(const char* format, Arguments... arguments)
{
    assert(format != nullptr);

    critical() << formatString(format, arguments...);
}

template <typename... Arguments> void fatal(const char* format, Arguments... arguments)
{
    assert(format != nullptr);

    fatal() << formatString(format, arguments...);
}

} // namespace globjects


text:
Facter.add("kernelmajversion") do
  setcode do
    Facter.value(:kernelversion).split('.')[0..1].join('.')
  end
end


text:
const fs = require('fs-extra');
const path = require('path');
const copyfiles = require('../utils/copyfiles');

/**
 * 在服务器端打包完成后
 * @async
 */
const buildServerAfter = async ({ dist }) => {
    if (process.env.WEBPACK_BUILD_ENV !== 'prod') return;

    const folder = path.resolve(__dirname, 'files-server-deploy');

    await copyfiles(
        fs
            .readdirSync(folder)
            .map((filename) => path.resolve(folder, filename)),
        'Copying server files that for deployment purpose'
    );
};

module.exports = buildServerAfter;


text:
// Template Source: BaseEntityRequest.java.tt
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All Rights Reserved.  Licensed under the MIT License.  See License in the project root for license information.
// ------------------------------------------------------------------------------

package com.microsoft.graph.requests;

import com.microsoft.graph.http.IRequestBuilder;
import com.microsoft.graph.core.ClientException;
import com.microsoft.graph.models.ChecklistItem;
import java.util.Arrays;
import java.util.EnumSet;
import javax.annotation.Nullable;
import javax.annotation.Nonnull;
import com.microsoft.graph.core.IBaseClient;
import com.microsoft.graph.http.BaseRequest;
import com.microsoft.graph.http.HttpMethod;

// **NOTE** This file was generated by a tool and any changes will be overwritten.

/**
 * The class for the Checklist Item Request.
 */
public class ChecklistItemRequest extends BaseRequest<ChecklistItem> {

    /**
     * The request for the ChecklistItem
     *
     * @param requestUrl     the request URL
     * @param client         the service client
     * @param requestOptions the options for this request
     */
    public ChecklistItemRequest(@Nonnull final String requestUrl, @Nonnull final IBaseClient<?> client, @Nullable final java.util.List<? extends com.microsoft.graph.options.Option> requestOptions) {
        super(requestUrl, client, requestOptions, ChecklistItem.class);
    }

    /**
     * Gets the ChecklistItem from the service
     *
     * @return a future with the result
     */
    @Nonnull
    public java.util.concurrent.CompletableFuture<ChecklistItem> getAsync() {
        return sendAsync(HttpMethod.GET, null);
    }

    /**
     * Gets the ChecklistItem from the service
     *
     * @return the ChecklistItem from the request
     * @throws ClientException this exception occurs if the request was unable to complete for any reason
     */
    @Nullable
    public ChecklistItem get() throws ClientException {
       return send(HttpMethod.GET, null);
    }

    /**
     * Delete this item from the service
     *
     * @return a future with the deletion result
     */
    @Nonnull
    public java.util.concurrent.CompletableFuture<ChecklistItem> deleteAsync() {
        return sendAsync(HttpMethod.DELETE, null);
    }

    /**
     * Delete this item from the service
     * @return the resulting response if the service returns anything on deletion
     *
     * @throws ClientException if there was an exception during the delete operation
     */
    @Nullable
    public ChecklistItem delete() throws ClientException {
        return send(HttpMethod.DELETE, null);
    }

    /**
     * Patches this ChecklistItem with a source
     *
     * @param sourceChecklistItem the source object with updates
     * @return a future with the result
     */
    @Nonnull
    public java.util.concurrent.CompletableFuture<ChecklistItem> patchAsync(@Nonnull final ChecklistItem sourceChecklistItem) {
        return sendAsync(HttpMethod.PATCH, sourceChecklistItem);
    }

    /**
     * Patches this ChecklistItem with a source
     *
     * @param sourceChecklistItem the source object with updates
     * @return the updated ChecklistItem
     * @throws ClientException this exception occurs if the request was unable to complete for any reason
     */
    @Nullable
    public ChecklistItem patch(@Nonnull final ChecklistItem sourceChecklistItem) throws ClientException {
        return send(HttpMethod.PATCH, sourceChecklistItem);
    }

    /**
     * Creates a ChecklistItem with a new object
     *
     * @param newChecklistItem the new object to create
     * @return a future with the result
     */
    @Nonnull
    public java.util.concurrent.CompletableFuture<ChecklistItem> postAsync(@Nonnull final ChecklistItem newChecklistItem) {
        return sendAsync(HttpMethod.POST, newChecklistItem);
    }

    /**
     * Creates a ChecklistItem with a new object
     *
     * @param newChecklistItem the new object to create
     * @return the created ChecklistItem
     * @throws ClientException this exception occurs if the request was unable to complete for any reason
     */
    @Nullable
    public ChecklistItem post(@Nonnull final ChecklistItem newChecklistItem) throws ClientException {
        return send(HttpMethod.POST, newChecklistItem);
    }

    /**
     * Creates a ChecklistItem with a new object
     *
     * @param newChecklistItem the object to create/update
     * @return a future with the result
     */
    @Nonnull
    public java.util.concurrent.CompletableFuture<ChecklistItem> putAsync(@Nonnull final ChecklistItem newChecklistItem) {
        return sendAsync(HttpMethod.PUT, newChecklistItem);
    }

    /**
     * Creates a ChecklistItem with a new object
     *
     * @param newChecklistItem the object to create/update
     * @return the created ChecklistItem
     * @throws ClientException this exception occurs if the request was unable to complete for any reason
     */
    @Nullable
    public ChecklistItem put(@Nonnull final ChecklistItem newChecklistItem) throws ClientException {
        return send(HttpMethod.PUT, newChecklistItem);
    }

    /**
     * Sets the select clause for the request
     *
     * @param value the select clause
     * @return the updated request
     */
     @Nonnull
     public ChecklistItemRequest select(@Nonnull final String value) {
         addSelectOption(value);
         return this;
     }

    /**
     * Sets the expand clause for the request
     *
     * @param value the expand clause
     * @return the updated request
     */
     @Nonnull
     public ChecklistItemRequest expand(@Nonnull final String value) {
         addExpandOption(value);
         return this;
     }

}


text:
using Ninject.Modules;
using Ninject.Selection.Heuristics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ninject.CoreContext
{
    /// <summary>
    /// Ninject context.
    /// </summary>
    public sealed class NinjectContext
    {
        /// <summary>
        /// The synchronize root object.
        /// </summary>
        static readonly object SyncRoot = new object();

        /// <summary>
        /// Single instance of the NinjectContext
        /// </summary>
        static readonly NinjectContext _instance = new NinjectContext();

        /// <summary>
		/// Ninject module to use in the context.
		/// </summary>
        readonly IList<INinjectModule> _modules = new List<INinjectModule>();

        /// <summary>
        /// True if NinjectContext was initialized, otherwise false
        /// </summary>
        static bool _initialized;

        /// <summary>
        /// Tue if AutoInjection is using
        /// </summary>
        bool _withAutoInjection;

        /// <summary>
        /// Gets a value indicating whether this instance is initialized.
        /// </summary>
        /// <value><c>true</c> if this instance is initialized; otherwise, <c>false</c>.</value>
        public bool Initialized
        {
            get
            {
                lock (SyncRoot)
                    return _initialized;
            }
        }

        /// <summary>
        /// Gets the modules.
        /// </summary>
        /// <value>The modules.</value>
        public IList<INinjectModule> Modules
        {
            get
            {
                lock (SyncRoot)
                    return _modules;
            }
        }

        /// <summary>
        /// Gets the inject types.
        /// </summary>
        /// <value>The inject types.</value>
        public IList<Type> InjectTypes
        {
            get
            {
                lock (SyncRoot)
                    return AutoInjection.ShouldInjectPropertyTypes;
            }
        }

        /// <summary>
        /// Use stack which be execute during initialize method
        /// </summary>
        private IList<Action<IKernel>> _useStack = new List<Action<IKernel>>();

        /// <summary>
        /// Adds the module.
        /// </summary>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public NinjectContext AddModule<T>() where T : class, INinjectModule
        {
            lock (SyncRoot)
            {
                if (Initialized) return this;

                var module = (T)Activator.CreateInstance(typeof(T));

                if (_modules.Any(x => x.GetType().Equals(module.GetType())))
                    return this;

                _modules.Add(module);
                return this;
            }
        }

        /// <summary>
        /// Activate the AutoInjection
        /// </summary>
        public NinjectContext WithAutoInjection()
        {
            lock (SyncRoot)
            {
                if (Initialized) return this;

                _withAutoInjection = true;
                return this;
            }
        }

        /// <summary>
        /// Use current action in the initialize method
        /// </summary>
        /// <param name="use">Use action</param>
        public void Use(Action<IKernel> use)
        {
            _useStack.Add(use);
        }

        /// <summary>
        /// Initialize this instance.
        /// </summary>
        public void Initialize()
        {
            lock (SyncRoot)
            {
                if (Initialized) return;

                var kernel = new StandardKernel(_modules.ToArray());
                if (_withAutoInjection)
                    kernel.Components.Add<IInjectionHeuristic, AutoInjection>();

                foreach (var use in _useStack)
                    use(kernel);

                _initialized = true;
            }
        }

        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <value>The instance.</value>
        public static NinjectContext Get()
        {
            lock (SyncRoot)
                return _instance;
        }
    }
}


text:
package hyplink.net.general;

import java.util.Random;

/** Convenient math methods */
public class MathUtils {
	// ========================= CONSTANTS =========================
	// ========================= VARIABLES =========================
	private static Random random = new Random();

	// ======================== CONSTRUCTORS =======================
	private MathUtils() { }

	// ====================== PUBLIC METHODS =======================
	public static void setSeed(long seed) {
		random.setSeed(seed);
	}

	/** Returns a random integer number */
	public static final int randomInt() {
		return random.nextInt();
	}

	/** Returns a random number between 0(inclusive) and the specified value(inclusive) */
	public static final int randomInt(int range) {
		return random.nextInt(range + 1);
	}

	/** Returns a random number between start(inclusive) and end(inclusive). */
	public static final int randomInt(int start, int end) {
		return start + random.nextInt(end - start + 1);
	}

	/** Returns a random boolean value. */
	public static final boolean randomBoolean() {
		return random.nextBoolean();
	}

	/** Returns true if a random value between 0 and 1 is less than the specified value. */
	public static final boolean randomBoolean(float chance) {
		return random.nextFloat() < chance;
	}

	/** Returns random number between 0.0(inclusive) and 1.0(exclusive). */
	public static final float randomFloat() {
		return random.nextFloat();
	}

	/** Returns a random number between 0(inclusive) and the specified value(exclusive). */
	public static final float randomFloat(float range) {
		return random.nextFloat() * range;
	}

	/** Returns a random number between start(inclusive) and end(exclusive). */
	public static final float randomFloat(float start, float end) {
		return start + random.nextFloat() * (end - start);
	}

    /** Returns the most positive (closest to positive infinity) of the two arguments.

     * Special cases:
     *

     *
{@code max(NaN, (anything)) = NaN}

     *
{@code max((anything), NaN) = NaN}

     *
{@code max(+0.0, -0.0) = +0.0}

     *
{@code max(-0.0, +0.0) = +0.0}

     *
 */
    public static double max(double d1, double d2) {
        if (d1 > d2) {
            return d1;
        }
        if (d1 < d2) {
            return d2;
        }
        /* if either arg is NaN, return NaN */
        if (d1 != d2) {
            return Double.NaN;
        }
        /* max(+0.0,-0.0) == +0.0 */
        /* Double.doubleToRawLongBits(0.0d) == 0 */
        if (Double.doubleToRawLongBits(d1) != 0) {
            return d2;
        }
        return 0.0d;
    }

    /** Returns the most positive (closest to positive infinity) of the two arguments.

     * Special cases:
     *

     *
{@code max(NaN, (anything)) = NaN}

     *
{@code max((anything), NaN) = NaN}

     *
{@code max(+0.0, -0.0) = +0.0}

     *
{@code max(-0.0, +0.0) = +0.0}

     *
 */
    public static float max(float f1, float f2) {
        if (f1 > f2) {
            return f1;
        }
        if (f1 < f2) {
            return f2;
        }
        /* if either arg is NaN, return NaN */
        if (f1 != f2) {
            return Float.NaN;
        }
        /* max(+0.0,-0.0) == +0.0 */
        /* Float.floatToRawIntBits(0.0f) == 0*/
        if (Float.floatToRawIntBits(f1) != 0) {
            return f2;
        }
        return 0.0f;
    }

    /** Returns the most positive (closest to positive infinity) of the two arguments. */
    public static int max(int i1, int i2) {
        return i1 > i2 ? i1 : i2;
    }

    /** Returns the most positive (closest to positive infinity) of the two arguments. */
    public static long max(long l1, long l2) {
        return l1 > l2 ? l1 : l2;
    }

    /** Returns the most negative (closest to negative infinity) of the two arguments.

     * Special cases:
     *

     *
{@code min(NaN, (anything)) = NaN}

     *
{@code min((anything), NaN) = NaN}

     *
{@code min(+0.0, -0.0) = -0.0}

     *
{@code min(-0.0, +0.0) = -0.0}

     *
 */
    public static double min(double d1, double d2) {
        if (d1 > d2) {
            return d2;
        }
        if (d1 < d2) {
            return d1;
        }
        /* if either arg is NaN, return NaN */
        if (d1 != d2) {
            return Double.NaN;
        }
        /* min(+0.0,-0.0) == -0.0 */
        /* 0x8000000000000000L == Double.doubleToRawLongBits(-0.0d) */
        if (Double.doubleToRawLongBits(d1) == 0x8000000000000000L) {
            return -0.0d;
        }
        return d2;
    }

    /** Returns the most negative (closest to negative infinity) of the two arguments.

     * Special cases:
     *

     *
{@code min(NaN, (anything)) = NaN}

     *
{@code min((anything), NaN) = NaN}

     *
{@code min(+0.0, -0.0) = -0.0}

     *
{@code min(-0.0, +0.0) = -0.0}

     *
 */
    public static float min(float f1, float f2) {
        if (f1 > f2) {
            return f2;
        }
        if (f1 < f2) {
            return f1;
        }
        /* if either arg is NaN, return NaN */
        if (f1 != f2) {
            return Float.NaN;
        }
        /* min(+0.0,-0.0) == -0.0 */
        /* 0x80000000 == Float.floatToRawIntBits(-0.0f) */
        if (Float.floatToRawIntBits(f1) == 0x80000000) {
            return -0.0f;
        }
        return f2;
    }

    /** Returns the most negative (closest to negative infinity) of the two arguments. */
    public static int min(int i1, int i2) {
        return i1 < i2 ? i1 : i2;
    }

    /** Returns the most negative (closest to negative infinity) of the two arguments. */
    public static long min(long l1, long l2) {
        return l1 < l2 ? l1 : l2;
    }

    /** Returns the absolute value of the argument.

     * Special cases:
     *

     *
{@code abs(-0.0) = +0.0}

     *
{@code abs(+infinity) = +infinity}

     *
{@code abs(-infinity) = +infinity}

     *
{@code abs(NaN) = NaN}

     *
 */
    public static double abs(double d) {
        return Double.longBitsToDouble(Double.doubleToRawLongBits(d) & 0x7fffffffffffffffL);
    }

    /** Returns the absolute value of the argument.

     * Special cases:
     *

     *
{@code abs(-0.0) = +0.0}

     *
{@code abs(+infinity) = +infinity}

     *
{@code abs(-infinity) = +infinity}

     *
{@code abs(NaN) = NaN}

     *
 */
    public static float abs(float f) {
        return Float.intBitsToFloat(Float.floatToRawIntBits(f) & 0x7fffffff);
    }

    /** Returns the absolute value of the argument. If the argument is {@code Integer.MIN_VALUE}, {@code Integer.MIN_VALUE} is returned. */
    public static int abs(int i) {
        return (i >= 0) ? i : -i;
    }

    /** Returns the absolute value of the argument. If the argument is {@code Long.MIN_VALUE}, {@code Long.MIN_VALUE} is returned. */
    public static long abs(long l) {
        return (l >= 0) ? l : -l;
    }

	// ===================== PROTECTED METHODS =====================
	// ====================== DEFAULT METHODS ======================
	// ====================== PRIVATE METHODS ======================
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>java.rmi.dgc (Java Platform SE 8 )</title>
<meta name="date" content="2014-12-17">
<meta name="keywords" content="java.rmi.dgc package">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">

java.rmi.dgc

Interfaces

DGC

Classes

Lease

VMID


text:
require File::expand_path('../../spec_helper', __FILE__)
require 'opbeat'

describe Opbeat::Event do
  describe '.from_message' do
    let(:message) { 'This is a message' }
    let(:hash) { Opbeat::Event.from_message(message, caller).to_hash }

    context 'for a Message' do
      it 'returns an event' do
        expect(Opbeat::Event.from_message(message, caller)).to be_a(Opbeat::Event)
      end

      it "sets the message to the value passed" do
        expect(hash['message']).to eq(message)
      end

      it 'has level ERROR' do
        expect(hash['level']).to eq('error')
      end
    end
  end

  describe '.from_exception' do
    let(:message) { 'This is a message' }
    let(:exception) {
      exc = Exception.new(message)
      exc.set_backtrace caller
      exc
    }
    let(:hash) { Opbeat::Event.from_exception(exception).to_hash }

    context 'for an Exception' do
      it 'returns an event' do
        expect(Opbeat::Event.from_exception(exception)).to be_a(Opbeat::Event)
      end

      it "sets the message to the exception's message and type" do
        expect(hash['message']).to eq("Exception: #{message}")
      end

      it 'has level ERROR' do
        expect(hash['level']).to eq('error')
      end

      it 'uses the exception class name as the exception type' do
        expect(hash['exception']['type']).to eq('Exception')
      end

      it 'uses the exception message as the exception value' do
        expect(hash['exception']['value']).to eq(message)
      end

      it 'does not belong to a module' do
        expect(hash['exception']['module']).to eq('')
      end
    end

    context 'for a nested exception type' do
      module Opbeat::Test
        class Exception < Exception; end
      end
      let(:exception) {
        exc = Opbeat::Test::Exception.new(message)
        exc.set_backtrace caller
        exc
      }

      it 'sends the module name as part of the exception info' do
        expect(hash['exception']['module']).to eq('Opbeat::Test')
      end
    end

    context 'for a Opbeat::Error' do
      let(:exception) { Opbeat::Error.new }
      it 'does not create an event' do
        expect(Opbeat::Event.from_exception(exception)).to be_nil
      end
    end

    context 'when the exception has a backtrace' do
      let(:exception) do
        e = Exception.new(message)
        allow(e).to receive(:backtrace).and_return([
          "/path/to/some/file:22:in `function_name'",
          "/some/other/path:1412:in `other_function'",
        ])
        e
      end

      it 'parses the backtrace' do
        expect(hash['stacktrace']['frames'].length).to eq(2)
        expect(hash['stacktrace']['frames'][0]['lineno']).to eq(1412)
        expect(hash['stacktrace']['frames'][0]['function']).to eq('other_function')
        expect(hash['stacktrace']['frames'][0]['filename']).to eq('/some/other/path')

        expect(hash['stacktrace']['frames'][1]['lineno']).to eq(22)
        expect(hash['stacktrace']['frames'][1]['function']).to eq('function_name')
        expect(hash['stacktrace']['frames'][1]['filename']).to eq('/path/to/some/file')
      end

      it "sets the culprit" do
        expect(hash['culprit']).to eq("/some/other/path in other_function")
      end

      context 'when a path in the stack trace is on the laod path' do
        before do
          $LOAD_PATH << '/some'
        end

        after do
          $LOAD_PATH.delete('/some')
        end

        it 'strips prefixes in the load path from frame filenames' do
          expect(hash['stacktrace']['frames'][0]['filename']).to eq('other/path')
        end
      end
    end

    context 'when there is user context' do
      it 'sends the context and is_authenticated' do
        Opbeat::Event.set_context(:user => {:id => 99})
        hash = Opbeat::Event.from_exception(exception).to_hash
        expect(hash['user']).to eq({:id => 99, :is_authenticated => true})
      end
    end

    context 'when there is extra context' do
      it 'sends the context and is_authenticated' do
        extra_context = {:jobid => 99}
        Opbeat::Event.set_context(:extra => extra_context)
        hash = Opbeat::Event.from_exception(exception).to_hash
        expect(hash['extra']).to eq(extra_context)
      end
    end
  end
end