List of usage examples for java.util.function Predicate test
boolean test(T t);
From source file:org.fenixedu.academic.domain.ExecutionYear.java
public List<ExecutionDegree> getExecutionDegreesFor(java.util.function.Predicate<DegreeType> predicate) { final List<ExecutionDegree> result = new ArrayList<ExecutionDegree>(); for (final ExecutionDegree executionDegree : getExecutionDegreesSet()) { if (predicate.test(executionDegree.getDegreeCurricularPlan().getDegree().getDegreeType())) { result.add(executionDegree); }// w w w .j av a 2s. c o m } return result; }
From source file:org.jbpm.workbench.pr.client.editors.instance.list.ProcessInstanceListPresenterTest.java
@Test public void testViewErrorsActionCondition() { doAnswer(new PerspectiveAnswer(EXECUTION_ERRORS)).when(authorizationManager) .authorize(any(ResourceRef.class), eq(identity)); ProcessInstanceSummary okProcInst = new ProcessInstanceSummary(); ProcessInstanceSummary errProcInst = new ProcessInstanceSummary(); errProcInst.setErrorCount(1);/*from ww w. j a va 2s . com*/ Predicate<ProcessInstanceSummary> viewErrCondition = presenter.getViewErrorsActionCondition(); assertFalse(viewErrCondition.test(okProcInst)); assertTrue(viewErrCondition.test(errProcInst)); when(authorizationManager.authorize(any(ResourceRef.class), eq(identity))).thenReturn(false); assertFalse(viewErrCondition.test(okProcInst)); assertFalse(viewErrCondition.test(errProcInst)); }
From source file:at.gridtec.lambda4j.operator.binary.BooleanBinaryOperator.java
/** * Returns a composed {@link BiPredicate2} that first applies the {@code before} predicates to its input, and * then applies this operator 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 predicate * @param <B> The type of the argument to the second given predicate, and of composed predicate * @param before1 The first predicate to apply before this operator is applied * @param before2 The second predicate to apply before this operator is applied * @return A composed {@code BiPredicate2} that first applies the {@code before} predicates to its input, and then * applies this operator to the result./*from www. ja v a 2s. co m*/ * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is able to handle every type. */ @Nonnull default <A, B> BiPredicate2<A, B> compose(@Nonnull final Predicate<? super A> before1, @Nonnull final Predicate<? super B> before2) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); return (a, b) -> applyAsBoolean(before1.test(a), before2.test(b)); }
From source file:io.github.jeddict.jpa.modeler.properties.PropertiesHandler.java
private static PropertyVisibilityHandler getMapKeyConvertVisibilityHandler( AttributeWidget<? extends Attribute> attributeWidget, Predicate<MapKeyHandler> filter) { PropertyVisibilityHandler mapKeyVisibility = AttributeWidget .getMapKeyVisibilityHandler(attributeWidget.getBaseElementSpec()); return () -> { if (mapKeyVisibility.isVisible()) { MapKeyHandler handler = (MapKeyHandler) attributeWidget.getBaseElementSpec(); return handler.getValidatedMapKeyType() == MapKeyType.NEW && filter.test(handler); }/*from www. ja v a 2 s.co m*/ return false; }; }
From source file:org.commonjava.util.partyline.FileTree.java
/** * Iterate all {@link FileEntry instances} to extract information about active locks. * * @param predicate The selector determining which files to analyze. * @param fileConsumer The operation to extract information from a single active file. */// w w w . j av a 2 s. c o m void forAll(Predicate<? super FileEntry> predicate, Consumer<FileEntry> fileConsumer) { TreeMap<String, FileEntry> sorted = new TreeMap<>(entryMap); sorted.forEach((key, entry) -> { if (entry != null && predicate.test(entry)) { fileConsumer.accept(entry); } }); }
From source file:at.gridtec.lambda4j.predicate.bi.obj.ObjBooleanPredicate.java
/** * Returns a composed {@link BiPredicate2} that first applies the {@code before} functions 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 <A> The type of the argument to the first given function, and of composed predicate * @param <B> The type of the argument to the second given predicate, and of composed predicate * @param before1 The first function to apply before this predicate is applied * @param before2 The second predicate to apply before this predicate is applied * @return A composed {@code BiPredicate2} that first applies the {@code before} functions 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. *///w w w . j a va2 s. c om @Nonnull default <A, B> BiPredicate2<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) -> test(before1.apply(a), before2.test(b)); }
From source file:com.github.rutledgepaulv.qbuilders.visitors.PredicateVisitor.java
protected boolean regex(Object actual, Object query) { Predicate<String> test; if (query instanceof String) { String queryRegex = (String) query; test = Pattern.compile(queryRegex).asPredicate(); } else {//from www .j av a 2s . com return false; } if (actual.getClass().isArray()) { String[] values = (String[]) actual; return Arrays.stream(values).anyMatch(test); } else if (Collection.class.isAssignableFrom(actual.getClass())) { Collection<String> values = (Collection<String>) actual; return values.stream().anyMatch(test); } else if (actual instanceof String) { return test.test((String) actual); } return false; }
From source file:org.briljantframework.array.AbstractComplexArray.java
@Override public BooleanArray where(Predicate<Complex> predicate) { BooleanArray bits = factory.newBooleanArray(getShape()); for (int i = 0; i < size(); i++) { bits.set(i, predicate.test(get(i))); }/*from w w w . j a v a 2 s .com*/ return bits; }
From source file:org.briljantframework.array.AbstractComplexArray.java
@Override public ComplexArray filter(Predicate<Complex> predicate) { IncrementalBuilder builder = new IncrementalBuilder(); for (int i = 0; i < size(); i++) { Complex value = get(i);/* w ww. j a v a 2 s . c om*/ if (predicate.test(value)) { builder.add(value); } } return builder.build(); }
From source file:org.jsweet.input.typescriptdef.ast.Scanner.java
@SuppressWarnings("unchecked") public <T extends Visitable> T getParent(Predicate<Visitable> predicate, boolean includeCurrent) { for (int i = this.stack.size() - (includeCurrent ? 1 : 2); i >= 0; i--) { if (predicate.test(this.stack.get(i))) { return (T) this.stack.get(i); }/*from w w w.ja v a2s . co m*/ } return null; }