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

io.github.mike10004.vhs.harbridge.LazyHarResponseData Maven / Gradle / Ivy

There is a newer version: 0.32
Show newest version
package io.github.mike10004.vhs.harbridge;

import com.google.common.io.ByteSource;
import com.google.common.net.MediaType;

import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

import static java.util.Objects.requireNonNull;

class LazyHarResponseData implements HarResponseData {

    private final Supplier bodySupplier;
    private final Supplier contentTypeSupplier;
    private final Supplier>> headersSupplier;

    public LazyHarResponseData(Supplier bodySupplier, Supplier contentTypeSupplier, Supplier>> headersSupplier) {
        this.bodySupplier = requireNonNull(bodySupplier);
        this.contentTypeSupplier = requireNonNull(contentTypeSupplier);
        this.headersSupplier = requireNonNull(headersSupplier);
    }

    @Override
    public List> headers() {
        return headersSupplier.get();
    }

    @Override
    public MediaType getContentType() {
        return contentTypeSupplier.get();
    }

    @Override
    public ByteSource getBody() {
        return bodySupplier.get();
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy