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

functionalj.stream.IntStreamElementProcessor Maven / Gradle / Ivy

There is a newer version: 1.0.17
Show newest version
package functionalj.stream;

import java.util.function.ToIntFunction;

import lombok.val;

public interface IntStreamElementProcessor {
    void processElement (long index, int element);
    T    processComplete(long count);
    
    default  StreamElementProcessor of(ToIntFunction mapper) {
        return new StreamElementProcessor() {
            @Override
            public void processElement(long index, S source) {
                val element = mapper.applyAsInt(source);
                IntStreamElementProcessor.this.processElement(index, element);
            }
            @Override
            public T processComplete(long count) {
                return IntStreamElementProcessor.this.processComplete(count);
            }
        };
    }
}