com.afrozaar.wordpress.wpapi.v2.request.SearchRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wp-api-v2-client-java Show documentation
Show all versions of wp-api-v2-client-java Show documentation
A Java client implementation to the WordPress WP-API v2 plugin.
package com.afrozaar.wordpress.wpapi.v2.request;
import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class SearchRequest extends Request {
private final Class clazz;
public SearchRequest(String uri, Map> params, Class clazz) {
super(uri, params);
this.clazz = clazz;
}
public Class getClazz() {
return clazz;
}
public static class Builder {
ImmutableMap.Builder> paramBuilder = new ImmutableMap.Builder<>();
String uri = Request.POSTS;
final Class clazz;
private Builder(Class clazz) {
this.clazz = clazz;
}
public static Builder aSearchRequest(Class clazz) {
return new Builder<>(clazz);
}
public Builder withParam(String key, String... values) {
paramBuilder.put(key, Arrays.asList(values));
return this;
}
public Builder withParams(Map> params) {
this.paramBuilder.putAll(params);
return this;
}
public Builder withUri(String uri) {
this.uri = uri;
return this;
}
public Builder but() {
return Builder.aSearchRequest(clazz).withParams(paramBuilder.build()).withUri(uri);
}
public SearchRequest build() {
return new SearchRequest<>(uri, paramBuilder.build(), clazz);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy