All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.avegera.stream.utils.Iterators Maven / Gradle / Ivy

Go to download

The library of laconic method-aliases for the safety Stream API operations on Java-collections

The newest version!
package io.github.avegera.stream.utils;

import java.util.Collection;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;

import static io.github.avegera.stream.utils.Streams.safeStream;


/**
 * For-each iterators method-aliases.
 * 

* The class contains laconic method-aliases for safe iteration through the collections in Java. * The result of class methods operations is {@link java.lang.Void}. */ public class Iterators { private Iterators() { //empty private constructor } public static void forEach(Collection collection, Consumer consumer) { safeStream(collection) .forEach(consumer); } public static void setForEach(Collection collection, BiConsumer setter, Function valueExtractor) { safeStream(collection) .forEach(item -> setter.accept(item, valueExtractor.apply(item))); } public static void setValueForEach(Collection collection, BiConsumer setter, R value) { safeStream(collection) .forEach(item -> setter.accept(item, value)); } //TODO: ADR whe different naming }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy