
org.mockserver.model.Body Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockserver-core Show documentation
Show all versions of mockserver-core Show documentation
Functionality used by all MockServer modules for matching and expectations
package org.mockserver.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.net.MediaType;
import java.nio.charset.Charset;
import static com.google.common.base.Charsets.UTF_8;
/**
* @author jamesdbloom
*/
public abstract class Body extends Not {
private final Type type;
public Body(Type type) {
this.type = type;
}
public Type getType() {
return type;
}
public abstract T getValue();
@JsonIgnore
public byte[] getRawBytes() {
return toString().getBytes(UTF_8);
}
@JsonIgnore
public Charset getCharset(Charset defaultIfNotSet) {
if (this instanceof BodyWithContentType) {
return this.getCharset(defaultIfNotSet);
}
return defaultIfNotSet;
}
public String getContentType() {
if (this instanceof BodyWithContentType) {
return this.getContentType();
}
return null;
}
public enum Type {
BINARY,
JSON,
JSON_SCHEMA,
PARAMETERS,
REGEX,
STRING,
XML,
XML_SCHEMA,
XPATH,
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy