Example usage for java.util.function Predicate test

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

Introduction

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

Prototype

boolean test(T t);

Source Link

Document

Evaluates this predicate on the given argument.

Usage

From source file:at.gridtec.lambda4j.function.bi.obj.ObjBooleanToIntFunction.java

/**
 * Returns a composed {@link ToIntBiFunction2} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given function, and of composed function
 * @param <B> The type of the argument to the second given predicate, and of composed function
 * @param before1 The first function to apply before this function is applied
 * @param before2 The second predicate to apply before this function is applied
 * @return A composed {@code ToIntBiFunction2} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 *///from  ww w . ja  v a2  s  .  co m
@Nonnull
default <A, B> ToIntBiFunction2<A, B> compose(@Nonnull final Function<? super A, ? extends T> before1,
        @Nonnull final Predicate<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> applyAsInt(before1.apply(a), before2.test(b));
}

From source file:at.gridtec.lambda4j.function.bi.obj.ObjBooleanToFloatFunction.java

/**
 * Returns a composed {@link ToFloatBiFunction} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given function, and of composed function
 * @param <B> The type of the argument to the second given predicate, and of composed function
 * @param before1 The first function to apply before this function is applied
 * @param before2 The second predicate to apply before this function is applied
 * @return A composed {@code ToFloatBiFunction} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 *///from   w  w w  . j a v  a2s  .c  om
@Nonnull
default <A, B> ToFloatBiFunction<A, B> compose(@Nonnull final Function<? super A, ? extends T> before1,
        @Nonnull final Predicate<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> applyAsFloat(before1.apply(a), before2.test(b));
}

From source file:at.gridtec.lambda4j.function.bi.obj.ObjBooleanToLongFunction.java

/**
 * Returns a composed {@link ToLongBiFunction2} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given function, and of composed function
 * @param <B> The type of the argument to the second given predicate, and of composed function
 * @param before1 The first function to apply before this function is applied
 * @param before2 The second predicate to apply before this function is applied
 * @return A composed {@code ToLongBiFunction2} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 *///from   ww w. j a  v a  2  s.  c o  m
@Nonnull
default <A, B> ToLongBiFunction2<A, B> compose(@Nonnull final Function<? super A, ? extends T> before1,
        @Nonnull final Predicate<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> applyAsLong(before1.apply(a), before2.test(b));
}

From source file:at.gridtec.lambda4j.function.bi.obj.ObjBooleanToShortFunction.java

/**
 * Returns a composed {@link ToShortBiFunction} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given function, and of composed function
 * @param <B> The type of the argument to the second given predicate, and of composed function
 * @param before1 The first function to apply before this function is applied
 * @param before2 The second predicate to apply before this function is applied
 * @return A composed {@code ToShortBiFunction} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 *///from w  ww . j  a va 2s. com
@Nonnull
default <A, B> ToShortBiFunction<A, B> compose(@Nonnull final Function<? super A, ? extends T> before1,
        @Nonnull final Predicate<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> applyAsShort(before1.apply(a), before2.test(b));
}

From source file:at.gridtec.lambda4j.function.bi.obj.ObjBooleanToDoubleFunction.java

/**
 * Returns a composed {@link ToDoubleBiFunction2} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given function, and of composed function
 * @param <B> The type of the argument to the second given predicate, and of composed function
 * @param before1 The first function to apply before this function is applied
 * @param before2 The second predicate to apply before this function is applied
 * @return A composed {@code ToDoubleBiFunction2} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 *//*w  w  w.  ja va2 s  . c  o  m*/
@Nonnull
default <A, B> ToDoubleBiFunction2<A, B> compose(@Nonnull final Function<? super A, ? extends T> before1,
        @Nonnull final Predicate<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> applyAsDouble(before1.apply(a), before2.test(b));
}

From source file:org.jactr.io.resolver.ASTResolver.java

/**
 * return the AST describing the chunktype and optionally all it's immediate
 * chunks//from   w  w w  .  j a  va2s  . co  m
 * 
 * @param chunkType
 * @param fullResolution
 * @return
 */
static public CommonTree toAST(IChunkType chunkType, Predicate<IChunk> chunkFilter) {
    ISymbolicChunkType sct = chunkType.getSymbolicChunkType();
    ISubsymbolicChunkType ssct = chunkType.getSubsymbolicChunkType();

    Collection<String> parentChunkTypeNames = new FastList<String>();

    for (IChunkType parent : sct.getParents())
        parentChunkTypeNames.add(parent.getSymbolicChunkType().getName());

    CommonTree cd = _support.createChunkTypeTree(sct.getName(), parentChunkTypeNames);

    setParameters(ASTSupport.getFirstDescendantWithType(cd, JACTRBuilder.PARAMETERS), ssct);

    // slots
    setSlots(ASTSupport.getFirstDescendantWithType(cd, JACTRBuilder.SLOTS), sct);

    if (chunkFilter != null) {
        CommonTree chunks = ASTSupport.getFirstDescendantWithType(cd, JACTRBuilder.CHUNKS);
        /*
         * process the chunks, but only include them if they are a direct child of
         * chunk type. leave descendants for the derived chunktypes to return
         */
        for (IChunk chunk : sct.getChunks())
            if (chunk.isAStrict(chunkType))
                if (chunkFilter.test(chunk))
                    chunks.addChild(toAST(chunk, false));
    }
    return cd;
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiBooleanToIntFunction.java

/**
 * Returns a composed {@link ToIntBiFunction2} that first applies the {@code before} predicates to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given predicate, and of composed function
 * @param <B> The type of the argument to the second given predicate, and of composed function
 * @param before1 The first predicate to apply before this function is applied
 * @param before2 The second predicate to apply before this function is applied
 * @return A composed {@code ToIntBiFunction2} that first applies the {@code before} predicates to its input, and
 * then applies this function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 *//*from   ww  w.j a  v  a2  s  .  com*/
@Nonnull
default <A, B> ToIntBiFunction2<A, B> compose(@Nonnull final Predicate<? super A> before1,
        @Nonnull final Predicate<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> applyAsInt(before1.test(a), before2.test(b));
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiBooleanToByteFunction.java

/**
 * Returns a composed {@link ToByteBiFunction} that first applies the {@code before} predicates to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given predicate, and of composed function
 * @param <B> The type of the argument to the second given predicate, and of composed function
 * @param before1 The first predicate to apply before this function is applied
 * @param before2 The second predicate to apply before this function is applied
 * @return A composed {@code ToByteBiFunction} that first applies the {@code before} predicates to its input, and
 * then applies this function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 *///from  ww  w . j  a v a 2 s. co m
@Nonnull
default <A, B> ToByteBiFunction<A, B> compose(@Nonnull final Predicate<? super A> before1,
        @Nonnull final Predicate<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> applyAsByte(before1.test(a), before2.test(b));
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiBooleanToCharFunction.java

/**
 * Returns a composed {@link ToCharBiFunction} that first applies the {@code before} predicates to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given predicate, and of composed function
 * @param <B> The type of the argument to the second given predicate, and of composed function
 * @param before1 The first predicate to apply before this function is applied
 * @param before2 The second predicate to apply before this function is applied
 * @return A composed {@code ToCharBiFunction} that first applies the {@code before} predicates to its input, and
 * then applies this function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 *///from w  w w  .j a va2 s  .  c om
@Nonnull
default <A, B> ToCharBiFunction<A, B> compose(@Nonnull final Predicate<? super A> before1,
        @Nonnull final Predicate<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> applyAsChar(before1.test(a), before2.test(b));
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiBooleanToLongFunction.java

/**
 * Returns a composed {@link ToLongBiFunction2} that first applies the {@code before} predicates to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given predicate, and of composed function
 * @param <B> The type of the argument to the second given predicate, and of composed function
 * @param before1 The first predicate to apply before this function is applied
 * @param before2 The second predicate to apply before this function is applied
 * @return A composed {@code ToLongBiFunction2} that first applies the {@code before} predicates to its input, and
 * then applies this function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 *//*w ww .  j a  v  a 2s  .co m*/
@Nonnull
default <A, B> ToLongBiFunction2<A, B> compose(@Nonnull final Predicate<? super A> before1,
        @Nonnull final Predicate<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> applyAsLong(before1.test(a), before2.test(b));
}