io.kroxylicious.proxy.config.model.VisitorWiretap Maven / Gradle / Ivy
package io.kroxylicious.proxy.config.model;
import java.util.Map.Entry;
import java.util.Collection;
import java.lang.Class;
import java.lang.Object;
import java.util.List;
import java.lang.String;
import java.lang.Boolean;
import java.util.Collections;
import java.util.function.Predicate;
public final class VisitorWiretap implements Visitor{
private VisitorWiretap(Visitor delegate,Collection listeners) {
this.delegate = delegate;
this.listeners = listeners;
}
private final Collection listeners;
private final Visitor delegate;
public static VisitorWiretap create(Visitor visitor,Collection listeners) {
if (visitor instanceof VisitorWiretap) {
return (VisitorWiretap) visitor;
}
return new VisitorWiretap(visitor, listeners);
}
public Class getType() {
return delegate.getType();
}
public void visit(T target) {
for (VisitorListener l : listeners) {
l.beforeVisit(delegate, Collections.emptyList(), target);
}
delegate.visit(target);
for (VisitorListener l : listeners) {
l.afterVisit(delegate, Collections.emptyList(), target);
}
}
public int order() {
return delegate.order();
}
public void visit(List> path,T target) {
for (VisitorListener l : listeners) {
l.beforeVisit(delegate, path, target);
}
delegate.visit(path, target);
for (VisitorListener l : listeners) {
l.afterVisit(delegate, path, target);
}
}
public Boolean canVisit(List> path,F target) {
boolean canVisit = delegate.canVisit(path, target);
for (VisitorListener l : listeners) {
l.onCheck(delegate, canVisit, target);
}
return canVisit;
}
}