org.zalando.logbook.LogbookCreator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of logbook-api Show documentation
Show all versions of logbook-api Show documentation
HTTP request and response logging
package org.zalando.logbook;
import lombok.Singular;
import org.apiguardian.api.API;
import javax.annotation.Nullable;
import java.util.List;
import java.util.function.Predicate;
import static org.apiguardian.api.API.Status.INTERNAL;
import static org.apiguardian.api.API.Status.STABLE;
@API(status = INTERNAL)
public final class LogbookCreator {
private LogbookCreator() {
}
@API(status = STABLE)
public static final class Builder {
}
@lombok.Builder(builderClassName = "Builder")
private static Logbook create(
@Nullable final Predicate condition,
@Singular final List queryFilters,
@Singular final List pathFilters,
@Singular final List headerFilters,
@Singular final List bodyFilters,
@Singular final List requestFilters,
@Singular final List responseFilters,
@Nullable final Strategy strategy,
@Nullable final Sink sink) {
@Nullable final QueryFilter queryFilter = queryFilters.stream()
.reduce(QueryFilter::merge)
.orElse(null);
@Nullable final PathFilter pathFilter = pathFilters.stream()
.reduce(PathFilter::merge)
.orElse(null);
@Nullable final HeaderFilter headerFilter = headerFilters.stream()
.reduce(HeaderFilter::merge)
.orElse(null);
@Nullable final BodyFilter bodyFilter = bodyFilters.stream()
.reduce(BodyFilter::merge)
.orElse(null);
@Nullable final RequestFilter requestFilter = requestFilters.stream()
.reduce(RequestFilter::merge)
.orElse(null);
@Nullable final ResponseFilter responseFilter = responseFilters.stream()
.reduce(ResponseFilter::merge)
.orElse(null);
final LogbookFactory factory = LogbookFactory.INSTANCE;
return factory.create(
condition,
queryFilter,
pathFilter,
headerFilter,
bodyFilter,
requestFilter,
responseFilter,
strategy,
sink);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy