/** * Transform session ID if ID transformer present. * * @param sesId Session ID to transform. * @return Transformed session ID or the same if no session transformer available. */ private String transformSessionId(final String sesId) { if (sesIdTransformer != null) return sesIdTransformer.apply(sesId); return sesId; }
/** {@inheritDoc} */ @Override public T next() { return trans.apply(cur = it.next()); }
/** {@inheritDoc} */ @Nullable @Override public Object execute() { return job.apply(arg); }
/** * Get IO policy for particular node with provided resolver. * * @param rslvr Resolver. * @param node Node. * @return IO policy. */ public static byte ioPolicy(@Nullable IgniteClosure<ClusterNode, Byte> rslvr, ClusterNode node) { assert node != null; Byte res = null; if (rslvr != null) res = rslvr.apply(node); if (res == null) res = DATA_STREAMER_POOL; return res; }
/** {@inheritDoc} */ @Nullable @Override public V1 get(Object key) { if (GridFunc.isAll((K)key, preds)) { V v = map.get(key); if (v != null) return clos.apply(v); } return null; }
/** * @param func Func. * @return Test builder. */ public JoinNodeTestPlanBuilder nodeConfiguration( IgniteClosure<IgniteConfiguration, IgniteConfiguration> func ) { nodeCfg = func.apply(nodeCfg); return this; }
/** {@inheritDoc} */ @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) { A.notNull(filePathClos, "filePathClos"); if (baseFileName == null) baseFileName = fileName; fileName = filePathClos.apply(baseFileName); }
@Override public T apply(IgniteInternalFuture<V> fut) { assert IgniteFutureImpl.this.fut == fut; try { return doneCb.apply(IgniteFutureImpl.this); } catch (Exception e) { throw new GridClosureException(e); } } };
/** {@inheritDoc} */ @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) { A.notNull(filePathClos, "filePathClos"); if (baseFileName == null) baseFileName = fileName; fileName = filePathClos.apply(baseFileName); }
/** {@inheritDoc} */ @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) { A.notNull(filePathClos, "filePathClos"); if (baseFileName == null) baseFileName = fileName; fileName = filePathClos.apply(baseFileName); } }
/** {@inheritDoc} */ @Nullable @Override public V get(Object key) { if (containsKey(key)) return clo.apply((K)key); return null; }
/** {@inheritDoc} */ @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) { A.notNull(filePathClos, "filePathClos"); if (baseFileName == null) baseFileName = fileName; fileName = filePathClos.apply(baseFileName); }
/** * @param trans Transformer. * @param evt Event. * @return Transformed value. */ private Object transform(IgniteClosure<CacheEntryEvent<? extends K, ? extends V>, ?> trans, CacheEntryEvent<? extends K, ? extends V> evt) { assert trans != null; Object transVal = null; try { transVal = trans.apply(evt); } catch (Exception e) { U.error(log, e); } return transVal; } }
/** * Transforms one collection to another using provided closure. New collection will be created. * * @param c Initial collection to transform. * @param f Closure to use for transformation. * @param <X> Type of the free variable for the closure and type of the collection elements. * @param <Y> Type of the closure's return value. * @return Transformed newly created collection. */ public static <X, Y> Collection<Y> transform(Collection<? extends X> c, IgniteClosure<? super X, Y> f) { A.notNull(c, "c", f, "f"); Collection<Y> d = new ArrayList<>(c.size()); for (X x : c) d.add(f.apply(x)); return d; }
/** * @param clo Message output closure. */ public void ackDataRegions(IgniteClosure<String, Void> clo) { DataStorageConfiguration memCfg = ctx.config().getDataStorageConfiguration(); if (memCfg == null) return; clo.apply("Data Regions Configured:"); clo.apply(dataRegionConfigurationMessage(memCfg.getDefaultDataRegionConfiguration())); DataRegionConfiguration[] dataRegions = memCfg.getDataRegionConfigurations(); if (dataRegions != null) { for (DataRegionConfiguration dataRegion : dataRegions) { String msg = dataRegionConfigurationMessage(dataRegion); if (msg != null) clo.apply(msg); } } }
/** * Finds, transforms and returns first element in given collection for which any of * the provided predicates evaluates to {@code true}. * * @param c Input collection. * @param dfltVal Default value to return when no element is found. * @param f Transforming closure. * @param p Optional set of finder predicates. * @param <V> Type of the collection elements. * @return First element in given collection for which predicate evaluates to * {@code true} - or {@code null} if such element cannot be found. */ @Deprecated public static <V, Y> Y find(Iterable<? extends V> c, @Nullable Y dfltVal, IgniteClosure<? super V, Y> f, @Nullable IgnitePredicate<? super V>... p) { A.notNull(c, "c", f, "f"); if (isAlwaysTrue(p) && c.iterator().hasNext()) return f.apply(c.iterator().next()); if (!isEmpty(p) && !isAlwaysFalse(p)) { for (V v : c) { if (isAny(v, p)) return f.apply(v); } } return dfltVal; }
closure.apply(grid);
long localCount = closure.apply(grid);