org.mockserver.model.JsonSchemaBody 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 org.mockserver.file.FileReader;
import java.util.Map;
import java.util.Objects;
/**
* @author jamesdbloom
*/
public class JsonSchemaBody extends Body {
private int hashCode;
private final String jsonSchema;
private Map parameterStyles;
public JsonSchemaBody(String jsonSchema) {
super(Type.JSON_SCHEMA);
this.jsonSchema = jsonSchema;
}
public static JsonSchemaBody jsonSchema(String jsonSchema) {
return new JsonSchemaBody(jsonSchema);
}
public static JsonSchemaBody jsonSchemaFromResource(String jsonSchemaPath) {
return new JsonSchemaBody(FileReader.readFileFromClassPathOrPath(jsonSchemaPath));
}
public Map getParameterStyles() {
return parameterStyles;
}
public JsonSchemaBody withParameterStyles(Map parameterStyles) {
this.parameterStyles = parameterStyles;
return this;
}
public String getValue() {
return jsonSchema;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (hashCode() != o.hashCode()) {
return false;
}
if (!super.equals(o)) {
return false;
}
JsonSchemaBody that = (JsonSchemaBody) o;
return Objects.equals(jsonSchema, that.jsonSchema);
}
@Override
public int hashCode() {
if (hashCode == 0) {
hashCode = Objects.hash(super.hashCode(), jsonSchema);
}
return hashCode;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy