io.polaris.core.function.Visitable Maven / Gradle / Ivy
package io.polaris.core.function;
import java.util.Iterator;
import java.util.function.Consumer;
import java.util.stream.Stream;
/**
* @author Qt
* @since 1.8, Sep 06, 2023
*/
@FunctionalInterface
public interface Visitable {
void visit(Consumer super T> visitor);
static Visitable of(Iterable iterable) {
return iterable::forEach;
}
static Visitable of(Iterator iterator) {
return iterator::forEachRemaining;
}
static Visitable of(Stream stream) {
return stream::forEach;
}
}