add method for simple string/string settings, work around fragile settings.put() method in ES 2.2

Jörg Prante 4 years ago
parent be2f18446b
commit 0a326977c7

@ -14,6 +14,7 @@ import org.xbib.elx.api.BasicClient;
import org.xbib.elx.api.SearchClientProvider;
import java.io.IOException;
import java.util.Map;
import java.util.ServiceLoader;
@SuppressWarnings("rawtypes")
@ -106,6 +107,25 @@ public class ClientBuilder {
return this;
}
public ClientBuilder put(Map<String, ?> map) {
for (Map.Entry<String, ?> entry : map.entrySet()) {
if (entry.getValue() == null) {
continue;
}
if (entry.getValue() instanceof String ||
entry.getValue() instanceof Integer ||
entry.getValue() instanceof Long ||
entry.getValue() instanceof Float ||
entry.getValue() instanceof TimeValue) {
settingsBuilder.put(entry.getKey(), entry.getValue().toString());
} else {
logger.log(Level.WARN, "skipping " + entry.getValue() +
" because invalid class type " + entry.getValue().getClass().getName());
}
}
return this;
}
@SuppressWarnings("unchecked")
public <C extends BasicClient> C build() throws IOException {
Settings settings = settingsBuilder.build();

@ -10,7 +10,7 @@ xbib-netty-http.version = 4.1.49.0
elasticsearch.version = 2.2.1
jackson.version = 2.9.10
jna.version = 4.5.2
log4j.version = 2.12.1
log4j.version = 2.13.1
mustache.version = 0.9.5
jts.version = 1.13
junit.version = 5.6.2

Loading…
Cancel
Save