Refine search
/** * Gets mapping by predicate. * * @param predicate * the predicate to decide if mapping should be filtered. Can be {@code null} */ public Map<String, String> getClassNameMapping(BiPredicate<String, String> predicate) { if (predicate == null) { return new HashMap<>(oldToNewClassNames); } return oldToNewClassNames.entrySet().stream().filter(entry -> predicate.test(entry.getKey(), entry.getValue())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }
public String[] getMechanismNames(final Map<String, ?> props) { BiPredicate<String, Provider> existing = SaslFactories.getProviderFilterPredicate(props); final HashMap<String, Object> newProps = new HashMap<String, Object>(props); if (existing != null) { newProps.put(SaslFactories.PROVIDER_FILTER_KEY, predicate.and(existing)); } else { newProps.put(SaslFactories.PROVIDER_FILTER_KEY, predicate); } return super.getMechanismNames(newProps); }
static <K, V, M extends Map<K, V>> M reject(M map, OfEntries<K, V, M> ofEntries, BiPredicate<? super K, ? super V> predicate) { Objects.requireNonNull(predicate, "predicate is null"); return filter(map, ofEntries, predicate.negate()); }
file, model, model.getGenerics().stream() .map(Generic::asType) .toArray(Type[]::new) ); .add("return this;"); if (onlyInclude.test(f, add)) { model.add(add); if (onlyInclude.test(f, set)) { model.add(set); .add("return this." + f.getName() + ";"); if (onlyInclude.test(f, get)) { model.add(get); .filter(Class.class::isInstance) .map(Class.class::cast) .forEach(c -> accept(file, c));
public static HeaderFilter removeHeaders(final BiPredicate<String, String> predicate) { return headers -> { final BaseHttpMessage.HeadersBuilder result = new BaseHttpMessage.HeadersBuilder(); headers.forEach((key, values) -> values.stream() .filter(value -> !predicate.test(key, value)) .forEach(value -> result.put(key, value))); return result.build(); }; }
public Map<String, List<SchemaField>> getTables(String project, BiPredicate<String, String> filter) { HashMap<String, List<SchemaField>> map = new HashMap<>(); for (TableColumn tableColumn : dao.listTableColumns(project, null)) { if (tableColumn.getColumnName().startsWith("$") || !filter.test(tableColumn.getTable().getTableName(), tableColumn.getColumnName())) { continue; } TypeSignature typeSignature = tableColumn.getDataType().getTypeSignature(); FieldType fieldType = PrestoQueryExecution.fromPrestoType(typeSignature.getBase(), typeSignature.getParameters().stream() .filter(param -> param.getKind() == TYPE) .map(param -> param.getTypeSignature().getBase()).iterator()); SchemaField column = new SchemaField(tableColumn.getColumnName(), fieldType); map.computeIfAbsent(tableColumn.getTable().getTableName(), key -> new ArrayList()).add(column); } return map; }
public static String table(BiPredicate<Boolean, Boolean> f) { List<String> resultBuilder = new ArrayList<>(); resultBuilder.add("A B result"); for (boolean a : Arrays.asList(true, false)) { for (boolean b : Arrays.asList(true, false)) { resultBuilder.add(String.format("%-10s %-10s %s", a, b, f.test(a, b))); } } return resultBuilder.stream().collect(Collectors.joining("\n")); }
/** * Returns whether any key-value pairs of this stream match the provided * predicate. May not evaluate the predicate on all elements if not * necessary for determining the result. If the stream is empty then * {@code false} is returned and the predicate is not evaluated. * <p> * This is a short-circuiting terminal operation. * * <p> * This method evaluates the <em>existential quantification</em> of the * predicate over the elements of the stream (for some x P(x)). * * @param predicate a non-interfering, stateless predicate to apply to * key-value pairs of this stream * @return {@code true} if any key-value pairs of the stream match * the provided predicate, otherwise {@code false} */ public boolean anyMatch(BiPredicate<? super K, ? super V> predicate) { return inner.anyMatch(e -> predicate.test(e.getKey(), e.getValue())); }
@Override public boolean tryReserveMemory(String allocationTag, long delta) { return tryReserveMemoryFunction.test(allocationTag, delta); } }
/** * Returns whether all key-value pairs of this stream match the provided * predicate. May not evaluate the predicate on all key-value pairs if not * necessary for determining the result. If the stream is empty then * {@code true} is returned and the predicate is not evaluated. * <p> * This is a short-circuiting terminal operation. * * <p> * This method evaluates the <em>universal quantification</em> of the * predicate over the elements of the stream (for all x P(x)). If the * stream is empty, the quantification is said to be <em>vacuously * satisfied</em> and is always {@code true} (regardless of P(x)). * * @param predicate a non-interfering, stateless predicate to apply to * key-value pairs of this stream * @return {@code true} if either all key-value pairs of the * stream match the provided predicate or the stream is * empty, otherwise {@code false} */ public boolean allMatch(BiPredicate<? super K, ? super V> predicate) { return inner.allMatch(e -> predicate.test(e.getKey(), e.getValue())); }
/** * Returns whether no key-value pairs of this stream match the provided * predicate. May not evaluate the predicate on all key-value pairs if not * necessary for determining the result. If the stream is empty then * {@code true} is returned and the predicate is not evaluated. * <p> * This is a short-circuiting terminal operation. * * <p> * This method evaluates the <em>universal quantification</em> of the * negated predicate over the elements of the stream (for all x ~P(x)). If * the stream is empty, the quantification is said to be vacuously satisfied * and is always {@code true}, regardless of P(x). * * @param predicate a non-interfering, stateless predicate to apply to * key-value pairs of this stream * @return {@code true} if either no key-value pairs of the * stream match the provided predicate or the stream is * empty, otherwise {@code false} */ public boolean noneMatch(BiPredicate<? super K, ? super V> predicate) { return inner.noneMatch(e -> predicate.test(e.getKey(), e.getValue())); }
/** * Group data in a Stream using knowledge of the current batch and the next entry to determing grouping limits * * @see Traversable#groupedUntil(BiPredicate) * * @param stream Stream to group * @param predicate Predicate to determine grouping * @return Stream grouped into Lists determined by predicate */ public final static <T> Stream<Seq<T>> groupedStatefullyUntil(final Stream<T> stream, final BiPredicate<Seq<? super T>, ? super T> predicate) { return StreamSupport.stream(new GroupedStatefullySpliterator<>(stream.spliterator(),()->Seq.of(),Function.identity(),predicate.negate()),stream.isParallel()); }
public <T> void register( String method, Class<T> eventType, BiPredicate<T, Map<String, String>> biPredicate) { eventService.subscribe( event -> remoteSubscriptionStorage .getByMethod(method) .stream() .filter(context -> biPredicate.test(event, context.getScope())) .forEach(context -> transmit(context.getEndpointId(), method, event)), eventType); }