
hope.kola.contract.restassured.AbstractCoderConfigBuilder Maven / Gradle / Ivy
package hope.kola.contract.restassured;
import static org.apache.commons.lang3.StringUtils.trim;
import io.restassured.http.ContentType;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractCoderConfigBuilder
implements Mergeable {
protected String defaultContentCharset;
protected Map contentTypeToDefaultCharset = new HashMap<>();
public void defaultCharsetForContentType(String charset, String contentType) {
contentTypeToDefaultCharset.put(trim(contentType).toLowerCase(), trim(charset));
}
public void defaultCharsetForContentType(String charset, ContentType contentType) {
final String _c = trim(charset);
for (String ct : contentType.getContentTypeStrings()) {
contentTypeToDefaultCharset.put(trim(ct).toLowerCase(), _c);
}
}
public void defaultCharsetForContentType(Charset charset, ContentType contentType) {
defaultCharsetForContentType(charset.toString(), contentType);
}
public void defaultContentCharsetUTF8() {
this.defaultContentCharset = StandardCharsets.UTF_8.name();
}
public void defaultContentCharset(String defaultContentCharset) {
this.defaultContentCharset = defaultContentCharset;
}
public void defaultContentCharset(Charset defaultContentCharset) {
this.defaultContentCharset = defaultContentCharset.name();
}
public Charset utf8() {
return StandardCharsets.UTF_8;
}
public Charset usAscii() {
return StandardCharsets.US_ASCII;
}
public ContentType any() {
return ContentType.ANY;
}
public ContentType text() {
return ContentType.TEXT;
}
public ContentType binary() {
return ContentType.BINARY;
}
public ContentType html() {
return ContentType.HTML;
}
public ContentType json() {
return ContentType.JSON;
}
public ContentType urlenc() {
return ContentType.URLENC;
}
public ContentType multipart() {
return ContentType.MULTIPART;
}
public ContentType xml() {
return ContentType.XML;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy