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

org.zalando.logbook.BodyReplacer Maven / Gradle / Ivy

There is a newer version: 3.10.0
Show newest version
package org.zalando.logbook;

import org.apiguardian.api.API;

import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Objects;

import static org.apiguardian.api.API.Status.STABLE;

@API(status = STABLE)
@FunctionalInterface
public interface BodyReplacer {

    @Nullable
    String replace(final T message);

    @SafeVarargs
    static  BodyReplacer composite(final BodyReplacer... replacers) {
        // TODO shouldn't this be a composite rather than first one wins?
        return message -> Arrays.stream(replacers)
                .map(replacer -> replacer.replace(message))
                .filter(Objects::nonNull)
                .findFirst()
                .orElse(null);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy