redis.clients.jedis.params.Params Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jredisearch-jedis Show documentation
Show all versions of jredisearch-jedis Show documentation
Jedis is a blazingly small and sane Redis java client. This is a fork of master
The newest version!
package redis.clients.jedis.params;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import redis.clients.jedis.util.SafeEncoder;
public abstract class Params {
private Map params;
@SuppressWarnings("unchecked")
public T getParam(String name) {
if (params == null) return null;
return (T) params.get(name);
}
public byte[][] getByteParams() {
ArrayList byteParams = new ArrayList();
for (Entry param : params.entrySet()) {
byteParams.add(SafeEncoder.encode(param.getKey()));
if (param.getValue() != null) {
byteParams.add(SafeEncoder.encode(String.valueOf(param.getValue())));
}
}
return byteParams.toArray(new byte[byteParams.size()][]);
}
protected boolean contains(String name) {
if (params == null) return false;
return params.containsKey(name);
}
protected void addParam(String name, Object value) {
if (params == null) {
params = new HashMap();
}
params.put(name, value);
}
protected void addParam(String name) {
if (params == null) {
params = new HashMap();
}
params.put(name, null);
}
}