Example usage for java.util.function IntPredicate test

List of usage examples for java.util.function IntPredicate test

Introduction

In this page you can find the example usage for java.util.function IntPredicate test.

Prototype

boolean test(int value);

Source Link

Document

Evaluates this predicate on the given argument.

Usage

From source file:Main.java

public static void main(String[] args) {
    IntPredicate i = (x) -> x < 0;

    System.out.println(i.test(123));

}

From source file:eu.openanalytics.shinyproxy.ShinyProxyTestStrategy.java

private static boolean retry(IntPredicate job, int tries, int waitTime, boolean retryOnException) {
    boolean retVal = false;
    RuntimeException exception = null;
    for (int currentTry = 1; currentTry <= tries; currentTry++) {
        try {/*from  ww w.j  a  v a2  s  . co  m*/
            if (job.test(currentTry)) {
                retVal = true;
                exception = null;
                break;
            }
        } catch (RuntimeException e) {
            if (retryOnException)
                exception = e;
            else
                throw e;
        }
        try {
            Thread.sleep(waitTime);
        } catch (InterruptedException ignore) {
        }
    }
    if (exception == null)
        return retVal;
    else
        throw exception;
}

From source file:at.gridtec.lambda4j.predicate.bi.BiIntPredicate.java

/**
 * Creates a {@link BiIntPredicate} which uses the {@code first} parameter of this one as argument for the given
 * {@link IntPredicate}./*from w  ww  .  jav  a 2s  .co  m*/
 *
 * @param predicate The predicate which accepts the {@code first} parameter of this one
 * @return Creates a {@code BiIntPredicate} which uses the {@code first} parameter of this one as argument for the
 * given {@code IntPredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static BiIntPredicate onlyFirst(@Nonnull final IntPredicate predicate) {
    Objects.requireNonNull(predicate);
    return (value1, value2) -> predicate.test(value1);
}

From source file:at.gridtec.lambda4j.predicate.bi.BiIntPredicate.java

/**
 * Creates a {@link BiIntPredicate} which uses the {@code second} parameter of this one as argument for the given
 * {@link IntPredicate}.//w w  w. j  a  va 2  s.co m
 *
 * @param predicate The predicate which accepts the {@code second} parameter of this one
 * @return Creates a {@code BiIntPredicate} which uses the {@code second} parameter of this one as argument for the
 * given {@code IntPredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static BiIntPredicate onlySecond(@Nonnull final IntPredicate predicate) {
    Objects.requireNonNull(predicate);
    return (value1, value2) -> predicate.test(value2);
}

From source file:at.gridtec.lambda4j.predicate.bi.obj.ObjIntPredicate.java

/**
 * Creates a {@link ObjIntPredicate} which uses the {@code second} parameter of this one as argument for the given
 * {@link IntPredicate}./*from w w  w  .  ja  va 2 s  .c o m*/
 *
 * @param <T> The type of the first argument to the predicate
 * @param predicate The predicate which accepts the {@code second} parameter of this one
 * @return Creates a {@code ObjIntPredicate} which uses the {@code second} parameter of this one as argument for the
 * given {@code IntPredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T> ObjIntPredicate<T> onlySecond(@Nonnull final IntPredicate predicate) {
    Objects.requireNonNull(predicate);
    return (t, value) -> predicate.test(value);
}

From source file:at.gridtec.lambda4j.predicate.tri.TriIntPredicate.java

/**
 * Creates a {@link TriIntPredicate} which uses the {@code first} parameter of this one as argument for the given
 * {@link IntPredicate}./*ww  w.ja  v a  2  s.c  o m*/
 *
 * @param predicate The predicate which accepts the {@code first} parameter of this one
 * @return Creates a {@code TriIntPredicate} which uses the {@code first} parameter of this one as argument for the
 * given {@code IntPredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static TriIntPredicate onlyFirst(@Nonnull final IntPredicate predicate) {
    Objects.requireNonNull(predicate);
    return (value1, value2, value3) -> predicate.test(value1);
}

From source file:at.gridtec.lambda4j.predicate.tri.TriIntPredicate.java

/**
 * Creates a {@link TriIntPredicate} which uses the {@code second} parameter of this one as argument for the given
 * {@link IntPredicate}.// w ww .  j  ava 2s. c  o m
 *
 * @param predicate The predicate which accepts the {@code second} parameter of this one
 * @return Creates a {@code TriIntPredicate} which uses the {@code second} parameter of this one as argument for the
 * given {@code IntPredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static TriIntPredicate onlySecond(@Nonnull final IntPredicate predicate) {
    Objects.requireNonNull(predicate);
    return (value1, value2, value3) -> predicate.test(value2);
}

From source file:at.gridtec.lambda4j.predicate.tri.TriIntPredicate.java

/**
 * Creates a {@link TriIntPredicate} which uses the {@code third} parameter of this one as argument for the given
 * {@link IntPredicate}.//w  w w.ja v a 2 s.co  m
 *
 * @param predicate The predicate which accepts the {@code third} parameter of this one
 * @return Creates a {@code TriIntPredicate} which uses the {@code third} parameter of this one as argument for the
 * given {@code IntPredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static TriIntPredicate onlyThird(@Nonnull final IntPredicate predicate) {
    Objects.requireNonNull(predicate);
    return (value1, value2, value3) -> predicate.test(value3);
}

From source file:at.gridtec.lambda4j.predicate.tri.obj.ObjBiIntPredicate.java

/**
 * Creates a {@link ObjBiIntPredicate} which uses the {@code second} parameter of this one as argument for the given
 * {@link IntPredicate}.//from w  w w .  jav  a  2  s  .  c om
 *
 * @param <T> The type of the first argument to the predicate
 * @param predicate The predicate which accepts the {@code second} parameter of this one
 * @return Creates a {@code ObjBiIntPredicate} which uses the {@code second} parameter of this one as argument for
 * the given {@code IntPredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T> ObjBiIntPredicate<T> onlySecond(@Nonnull final IntPredicate predicate) {
    Objects.requireNonNull(predicate);
    return (t, value1, value2) -> predicate.test(value1);
}

From source file:at.gridtec.lambda4j.predicate.tri.obj.ObjBiIntPredicate.java

/**
 * Creates a {@link ObjBiIntPredicate} which uses the {@code third} parameter of this one as argument for the given
 * {@link IntPredicate}.//  w  ww.j  a va  2  s.co m
 *
 * @param <T> The type of the first argument to the predicate
 * @param predicate The predicate which accepts the {@code third} parameter of this one
 * @return Creates a {@code ObjBiIntPredicate} which uses the {@code third} parameter of this one as argument for
 * the given {@code IntPredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T> ObjBiIntPredicate<T> onlyThird(@Nonnull final IntPredicate predicate) {
    Objects.requireNonNull(predicate);
    return (t, value1, value2) -> predicate.test(value2);
}