/** {@inheritDoc} */ @Override public final GridPredicate<GridNode> predicate() { return p != null ? p : F.<GridNode>alwaysTrue(); }
/** * @return Empty filter. */ public GridPredicate<GridCacheEntry<K, V>> truex() { return F.alwaysTrue(); }
/** * @param nodeId Node ID. * @return Filter. */ private GridPredicate<GridCacheMvccCandidate<K>> nodeIdFilter(final UUID nodeId) { if (nodeId == null) return F.alwaysTrue(); return new P1<GridCacheMvccCandidate<K>>() { @Override public boolean apply(GridCacheMvccCandidate<K> c) { UUID otherId = c.otherNodeId(); return c.nodeId().equals(nodeId) || (otherId != null && otherId.equals(nodeId)); } }; }
/** * Negates given predicates. * <p> * Gets predicate (not peer-deployable) that evaluates to {@code true} if any of given predicates * evaluates to {@code false}. If all predicates evaluate to {@code true} the * result predicate will evaluate to {@code false}. * * @param p Predicate to negate. * @param <T> Type of the free variable, i.e. the element the predicate is called on. * @return Negated predicate (not peer-deployable). */ public static <T> GridPredicate<T> not(@Nullable final GridPredicate<? super T>... p) { return F.isAlwaysFalse(p) ? F.<T>alwaysTrue() : F.isAlwaysTrue(p) ? F.<T>alwaysFalse() : new P1<T>() { @Override public boolean apply(T t) { return !F.isAll(t, p); } }; }
public static <T> GridPredicate<T> and(@Nullable final GridPredicate<? super T>... ps) { if (isEmpty(ps)) return F.alwaysTrue(); return F.alwaysTrue();
/** * Converts value filter to entry filter using {@link GridCacheEntry#get()} to get value. * Note that if array of provided filters is {@code null} or empty this method returns * predicate that evaluates to {@code true} when applying. * * @param ps Value filter(s) to convert. * @return Entry filter. */ public static <K, V> GridPredicate<GridCacheEntry<K, V>> cacheValuesGet( @Nullable final GridPredicate<? super V>... ps) { return isEmpty(ps) || isAlwaysTrue(ps) ? F.<GridCacheEntry<K, V>>alwaysTrue() : isAlwaysFalse(ps) ? F.<GridCacheEntry<K, V>>alwaysFalse() : new GridPredicate<GridCacheEntry<K, V>>() { @Override public boolean apply(GridCacheEntry<K, V> e) { try { V v = e.get(); return v != null && F.isAll(v, ps); } catch (GridException ex) { throw wrap(ex); } } }; }
public static <T> GridPredicate<T> and(@Nullable final Collection<? extends GridPredicate<? super T>> ps) { if (isEmpty(ps)) return F.alwaysTrue();
/** * Gets event predicate that returns {@code true} only if node that produced the event * satisfies all given predicates. Note that if array of provided node predicates is * {@code null} or empty this method returns predicate that evaluates to {@code true} * assuming that any event produced by any node is ok. * * @param gridName Grid name. * @param p Node predicates. * @return Event predicate. */ public static GridPredicate<GridEvent> eventNode(@Nullable final String gridName, @Nullable final GridPredicate<GridNode>... p) { return isEmpty(p) || isAlwaysTrue(p) ? F.<GridEvent>alwaysTrue() : isAlwaysFalse(p) ? F.<GridEvent>alwaysFalse() : new GridPredicate<GridEvent>() { @Override public boolean apply(GridEvent e) { assert e != null; try { GridNode node = G.grid(gridName).node(e.node().id()); return isAll(node, p); } catch (IllegalStateException ex) { throw new GridRuntimeException("Invalid grid name: " + gridName, ex); } } }; }
/** * Negates given predicates. * <p> * Gets predicate that evaluates to {@code true} if any of given predicates * evaluates to {@code false}. If all predicates evaluate to {@code true} the * result predicate will evaluate to {@code false}. * * @param p Predicate to negate. * @param <T> Type of the free variable, i.e. the element the predicate is called on. * @return Negated predicate. */ public static <T> GridPredicate<T> not(@Nullable final GridPredicate<? super T>... p) { return isAlwaysFalse(p) ? F.<T>alwaysTrue() : isAlwaysTrue(p) ? F.<T>alwaysFalse() : new P1<T>() { @Override public boolean apply(T t) { return !isAll(t, p); } }; }
/** * Converts value filter to entry filter using {@link GridCacheEntry#peek()} * to get value. Note that if array of provided filters is {@code null} or empty this method returns * predicate that evaluates to {@code true} when applying. * * @param ps Value filter(s) to convert. * @return Entry filter. */ public static <K, V> GridPredicate<GridCacheEntry<K, V>> cacheValuesPeek( @Nullable final GridPredicate<? super V>... ps) { return isEmpty(ps) || isAlwaysTrue(ps) ? F.<GridCacheEntry<K, V>>alwaysTrue() : isAlwaysFalse(ps) ? F.<GridCacheEntry<K, V>>alwaysFalse() : new GridPredicate<GridCacheEntry<K, V>>() { @Override public boolean apply(GridCacheEntry<K, V> e) { V v = e.peek(); return v != null && F.isAll(v, ps); } }; }
) { if (p == null && F.isEmptyOrNulls(ps)) return F.alwaysTrue(); return F.alwaysTrue();
/** * Converts key filter to entry filter using {@link GridCacheEntry#getKey()} * to get value. Note that if array of provided filters is {@code null} or empty this * method returns predicate that evaluates to {@code true} when applying. * * @param ps Key filter(s) to convert. * @return Entry filter. */ public static <K, V> GridPredicate<GridCacheEntry<K, V>> cacheKeys( @Nullable final GridPredicate<? super K>... ps) { return isEmpty(ps) || isAlwaysTrue(ps) ? F.<GridCacheEntry<K, V>>alwaysTrue() : isAlwaysFalse(ps) ? F.<GridCacheEntry<K, V>>alwaysFalse() : new GridPredicate<GridCacheEntry<K, V>>() { @Override public boolean apply(GridCacheEntry<K, V> e) { return F.isAll(e.getKey(), ps); } }; }
/** * Gets a predicate that is composed of given predicate and closure. For every {@code x} * it returns predicate {@code p(f(x))}. Note that predicate and closure must be loaded * by the same class loader. * * @param p Predicate. * @param f Closure. * @param <X> Type of the free variable for the closure. * @param <Y> Type of the closure's return value. * @return Predicate that is composed of given predicate and closure. */ @SuppressWarnings({"JavaDoc"}) public static <X, Y> GridPredicate<X> compose(final GridPredicate<? super Y> p, final GridClosure<? super X, ? extends Y> f) { A.notNull(p, "p", f, "f"); return isAlwaysFalse(p) ? F.<X>alwaysFalse() : isAlwaysTrue(p) ? F.<X>alwaysTrue() : new P1<X>() { @Override public boolean apply(X x) { return p.apply(f.apply(x)); } }; }
return F.alwaysTrue(); return F.alwaysTrue();
return F.alwaysTrue(); return F.alwaysTrue();
else { if (isAlwaysTrue(ps)) return F.alwaysTrue(); else { if (F0.isAllNodePredicates(ps)) {
/** * @param name Service name. * @param svc Service. * @param totalCnt Total count. * @param maxPerNodeCnt Max per-node count. * @return Future. */ public GridFuture<?> deployMultiple(GridProjection prj, String name, GridService svc, int totalCnt, int maxPerNodeCnt) { GridServiceConfiguration cfg = new GridServiceConfiguration(); cfg.setName(name); cfg.setService(svc); cfg.setTotalCount(totalCnt); cfg.setMaxPerNodeCount(maxPerNodeCnt); cfg.setNodeFilter(F.<GridNode>alwaysTrue() == prj.predicate() ? null : prj.predicate()); return deploy(cfg); }
return F.alwaysTrue();
throws ClassNotFoundException { GridPredicate<GridCacheEntry<Object, Object>> prjPred = req.projectionFilter() == null ? F.<GridCacheEntry<Object, Object>>alwaysTrue() : req.projectionFilter();
noPeekArr = new GridPredicate[]{F.cacheNoPeekValue()}; hasPeekArr = new GridPredicate[]{F.cacheHasPeekValue()}; trueArr = new GridPredicate[]{F.alwaysTrue()};