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

com.github.scr.j8iterables.core.ConsumingIdentity Maven / Gradle / Ivy

package com.github.scr.j8iterables.core;

import com.google.common.base.Function;
import org.jetbrains.annotations.NotNull;

import java.util.function.Consumer;
import java.util.function.UnaryOperator;

/**
 * Utility to enable Stream-like "peek" on an Iterable.
 *
 * @author scr
 */
public class ConsumingIdentity implements Function, UnaryOperator {
    @NotNull
    private final Consumer CONSUMER;

    public ConsumingIdentity(@NotNull Consumer consumer) {
        CONSUMER = consumer;
    }

    @Override
    public T apply(T t) {
        CONSUMER.accept(t);
        return t;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy