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

org.mockserver.model.Header Maven / Gradle / Ivy

There is a newer version: 5.15.0
Show newest version
package org.mockserver.model;

import java.util.Arrays;
import java.util.Collection;

import static org.mockserver.model.NottableOptionalString.optional;
import static org.mockserver.model.NottableString.string;

/**
 * @author jamesdbloom
 */
public class Header extends KeyToMultiValue {

    public Header(String name, String... value) {
        super(name, value);
    }

    public Header(NottableString name, NottableString... value) {
        super(name, value);
    }

    public Header(NottableString name, String... value) {
        super(name, value);
    }

    public Header(String name, Collection value) {
        super(name, value);
    }

    public Header(NottableString name, Collection value) {
        super(name, value);
    }

    public static Header header(String name, int value) {
        return new Header(name, String.valueOf(value));
    }

    public static Header header(String name, String... value) {
        return new Header(name, value);
    }

    public static Header header(NottableString name, NottableString... value) {
        return new Header(name, value);
    }

    public static Header header(String name, Collection value) {
        return new Header(name, value);
    }

    public static Header header(NottableString name, Collection value) {
        return new Header(name, value);
    }

    public static Header schemaHeader(String name, String... values) {
        if (values.length == 0) {
            values = new String[]{".*"};
        }
        return new Header(string(name), Arrays.stream(values).map(NottableSchemaString::schemaString).toArray(NottableString[]::new));
    }

    public static Header optionalHeader(String name, String... values) {
        if (values.length == 0) {
            values = new String[]{".*"};
        }
        return new Header(optional(name), Arrays.stream(values).map(NottableString::string).toArray(NottableString[]::new));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy