/** * Returns a stream consisting of the elements of this stream which value is * not null. * * <p> * This is an <a href="package-summary.html#StreamOps">intermediate</a> * operation. * * @return the new stream */ public EntryStream<K, V> nonNullValues() { return filter(e -> e.getValue() != null); }
/** * Returns a stream consisting of the elements of this stream which key is * not null. * * <p> * This is an <a href="package-summary.html#StreamOps">intermediate</a> * operation. * * @return the new stream */ public EntryStream<K, V> nonNullKeys() { return filter(e -> e.getKey() != null); }
/** * Returns a stream consisting of the elements of this stream which keys are * instances of given class. * * <p> * This is an <a href="package-summary.html#StreamOps">intermediate</a> * operation. * * @param <KK> a type of keys to select. * @param clazz a class to filter the keys. * @return the new stream */ @SuppressWarnings({ "unchecked" }) public <KK> EntryStream<KK, V> selectKeys(Class<KK> clazz) { return (EntryStream<KK, V>) filter(e -> clazz.isInstance(e.getKey())); }
/** * Returns a stream consisting of the elements of this stream which values * match the given predicate. * * <p> * This is an <a href="package-summary.html#StreamOps">intermediate</a> * operation. * * @param valuePredicate a non-interfering, stateless predicate to apply to * the value of each element to determine if it should be included * @return the new stream */ public EntryStream<K, V> filterValues(Predicate<? super V> valuePredicate) { return filter(e -> valuePredicate.test(e.getValue())); }
/** * Returns a stream consisting of the elements of this stream which keys * match the given predicate. * * <p> * This is an <a href="package-summary.html#StreamOps">intermediate</a> * operation. * * @param keyPredicate a non-interfering, stateless predicate to apply to * the key of each element to determine if it should be included * @return the new stream */ public EntryStream<K, V> filterKeys(Predicate<? super K> keyPredicate) { return filter(e -> keyPredicate.test(e.getKey())); }
/** * Returns a stream consisting of the elements of this stream which values * are instances of given class. * * <p> * This is an <a href="package-summary.html#StreamOps">intermediate</a> * operation. * * @param <VV> a type of values to select. * @param clazz a class to filter the values. * @return the new stream */ @SuppressWarnings({ "unchecked" }) public <VV> EntryStream<K, VV> selectValues(Class<VV> clazz) { return (EntryStream<K, VV>) filter(e -> clazz.isInstance(e.getValue())); }
/** * Returns a stream consisting of the elements of this stream which elements * match the given predicate. * * <p> * This is an <a href="package-summary.html#StreamOps">intermediate</a> * operation. * * @param predicate a non-interfering, stateless predicate to apply to the * key-value pairs of each element to determine if it should be * included * @return the new stream * @since 0.3.0 */ public EntryStream<K, V> filterKeyValue(BiPredicate<? super K, ? super V> predicate) { return filter(e -> predicate.test(e.getKey(), e.getValue())); }