redis.clients.jedis.graph.RedisGraphQueryUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jedis_preview Show documentation
Show all versions of jedis_preview Show documentation
Jedis is a blazingly small and sane Redis java client.
The newest version!
package redis.clients.jedis.graph;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @deprecated Redis Graph support is deprecated.
*/
@Deprecated
public class RedisGraphQueryUtil {
public static final List DUMMY_LIST = Collections.emptyList();
public static final Map> DUMMY_MAP = Collections.emptyMap();
public static final String COMPACT_STRING = "--COMPACT";
public static final String TIMEOUT_STRING = "TIMEOUT";
private RedisGraphQueryUtil() {
}
/**
* Prepare and formats a query and query arguments
*
* @param query - query
* @param params - query parameters
* @return query with parameters header
* @deprecated Redis Graph support is deprecated.
*/
@Deprecated
public static String prepareQuery(String query, Map params) {
StringBuilder sb = new StringBuilder("CYPHER ");
for (Map.Entry entry : params.entrySet()) {
sb
.append(entry.getKey())
.append('=')
.append(valueToString(entry.getValue()))
.append(' ');
}
sb.append(query);
return sb.toString();
}
private static String valueToString(Object value) {
if (value == null) {
return "null";
}
if (value instanceof String) {
return quoteString((String) value);
}
if (value instanceof Character) {
return quoteString(((Character) value).toString());
}
if (value instanceof Object[]) {
return arrayToString((Object[]) value);
}
if (value instanceof List) {
return arrayToString((List