pipeline return formatted values
This commit is contained in:
@@ -2019,11 +2019,13 @@ public class BinaryJedis implements BinaryJedisCommands {
|
||||
public List<Object> pipelined(final PipelineBlock jedisPipeline) {
|
||||
jedisPipeline.setClient(client);
|
||||
jedisPipeline.execute();
|
||||
return client.getAll();
|
||||
return jedisPipeline.sync();
|
||||
}
|
||||
|
||||
public Pipeline pipelined() {
|
||||
return new Pipeline(client);
|
||||
Pipeline pipeline = new Pipeline();
|
||||
pipeline.setClient(client);
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
public void subscribe(final JedisPubSub jedisPubSub,
|
||||
|
||||
5
src/main/java/redis/clients/jedis/Builder.java
Normal file
5
src/main/java/redis/clients/jedis/Builder.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
public abstract class Builder<T> {
|
||||
public abstract T build(Object data);
|
||||
}
|
||||
163
src/main/java/redis/clients/jedis/BuilderFactory.java
Normal file
163
src/main/java/redis/clients/jedis/BuilderFactory.java
Normal file
@@ -0,0 +1,163 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import redis.clients.util.SafeEncoder;
|
||||
|
||||
public class BuilderFactory {
|
||||
public static final Builder<Double> DOUBLE = new Builder<Double>() {
|
||||
public Double build(Object data) {
|
||||
return Double.valueOf((Long) data);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "double";
|
||||
}
|
||||
};
|
||||
public static final Builder<Boolean> BOOLEAN = new Builder<Boolean>() {
|
||||
public Boolean build(Object data) {
|
||||
return ((Long) data) == 1;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "boolean";
|
||||
}
|
||||
};
|
||||
public static final Builder<Long> LONG = new Builder<Long>() {
|
||||
public Long build(Object data) {
|
||||
return (Long) data;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "long";
|
||||
}
|
||||
|
||||
};
|
||||
public static final Builder<String> STRING = new Builder<String>() {
|
||||
public String build(Object data) {
|
||||
return SafeEncoder.encode((byte[]) data);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "string";
|
||||
}
|
||||
|
||||
};
|
||||
public static final Builder<List<String>> STRING_LIST = new Builder<List<String>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> build(Object data) {
|
||||
if (null == data) {
|
||||
return null;
|
||||
}
|
||||
List<byte[]> l = (List<byte[]>) data;
|
||||
final ArrayList<String> result = new ArrayList<String>(l.size());
|
||||
for (final byte[] barray : l) {
|
||||
if (barray == null) {
|
||||
result.add(null);
|
||||
} else {
|
||||
result.add(SafeEncoder.encode(barray));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "List<String>";
|
||||
}
|
||||
|
||||
};
|
||||
public static final Builder<Map<String, String>> STRING_MAP = new Builder<Map<String, String>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, String> build(Object data) {
|
||||
final List<byte[]> flatHash = (List<byte[]>) data;
|
||||
final Map<String, String> hash = new HashMap<String, String>();
|
||||
final Iterator<byte[]> iterator = flatHash.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
hash.put(SafeEncoder.encode(iterator.next()), SafeEncoder
|
||||
.encode(iterator.next()));
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Map<String, String>";
|
||||
}
|
||||
|
||||
};
|
||||
public static final Builder<Set<String>> STRING_SET = new Builder<Set<String>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set<String> build(Object data) {
|
||||
if (null == data) {
|
||||
return null;
|
||||
}
|
||||
List<byte[]> l = (List<byte[]>) data;
|
||||
final Set<String> result = new HashSet<String>(l.size());
|
||||
for (final byte[] barray : l) {
|
||||
if (barray == null) {
|
||||
result.add(null);
|
||||
} else {
|
||||
result.add(SafeEncoder.encode(barray));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Set<String>";
|
||||
}
|
||||
|
||||
};
|
||||
public static final Builder<Set<String>> STRING_ZSET = new Builder<Set<String>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set<String> build(Object data) {
|
||||
if (null == data) {
|
||||
return null;
|
||||
}
|
||||
List<byte[]> l = (List<byte[]>) data;
|
||||
final Set<String> result = new LinkedHashSet<String>(l.size());
|
||||
for (final byte[] barray : l) {
|
||||
if (barray == null) {
|
||||
result.add(null);
|
||||
} else {
|
||||
result.add(SafeEncoder.encode(barray));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ZSet<String>";
|
||||
}
|
||||
|
||||
};
|
||||
public static final Builder<Set<Tuple>> TUPLE_ZSET = new Builder<Set<Tuple>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set<Tuple> build(Object data) {
|
||||
if (null == data) {
|
||||
return null;
|
||||
}
|
||||
List<byte[]> l = (List<byte[]>) data;
|
||||
final Set<Tuple> result = new LinkedHashSet<Tuple>(l.size());
|
||||
Iterator<byte[]> iterator = l.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
result.add(new Tuple(SafeEncoder.encode(iterator.next()),
|
||||
Double.valueOf(SafeEncoder.encode(iterator.next()))));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ZSet<Tuple>";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -175,19 +175,7 @@ public class Connection {
|
||||
}
|
||||
|
||||
public List<String> getMultiBulkReply() {
|
||||
final List<byte[]> bresult = getBinaryMultiBulkReply();
|
||||
if (null == bresult) {
|
||||
return null;
|
||||
}
|
||||
final ArrayList<String> result = new ArrayList<String>(bresult.size());
|
||||
for (final byte[] barray : bresult) {
|
||||
if (barray == null) {
|
||||
result.add(null);
|
||||
} else {
|
||||
result.add(SafeEncoder.encode(barray));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return BuilderFactory.STRING_LIST.build(getBinaryMultiBulkReply());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -175,9 +174,8 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
public Set<String> keys(final String pattern) {
|
||||
runChecks();
|
||||
client.keys(pattern);
|
||||
final HashSet<String> keySet = new HashSet<String>(client
|
||||
.getMultiBulkReply());
|
||||
return keySet;
|
||||
return BuilderFactory.STRING_SET
|
||||
.build(client.getBinaryMultiBulkReply());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -830,8 +828,8 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
public Set<String> hkeys(final String key) {
|
||||
runChecks();
|
||||
client.hkeys(key);
|
||||
final List<String> lresult = client.getMultiBulkReply();
|
||||
return new HashSet<String>(lresult);
|
||||
return BuilderFactory.STRING_SET
|
||||
.build(client.getBinaryMultiBulkReply());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -860,14 +858,8 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
public Map<String, String> hgetAll(final String key) {
|
||||
runChecks();
|
||||
client.hgetAll(key);
|
||||
final List<String> flatHash = client.getMultiBulkReply();
|
||||
final Map<String, String> hash = new HashMap<String, String>();
|
||||
final Iterator<String> iterator = flatHash.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
hash.put(iterator.next(), iterator.next());
|
||||
}
|
||||
|
||||
return hash;
|
||||
return BuilderFactory.STRING_MAP
|
||||
.build(client.getBinaryMultiBulkReply());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1393,8 +1385,8 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
public Set<String> sdiff(final String... keys) {
|
||||
runChecks();
|
||||
client.sdiff(keys);
|
||||
final List<String> members = client.getMultiBulkReply();
|
||||
return new HashSet<String>(members);
|
||||
return BuilderFactory.STRING_SET
|
||||
.build(client.getBinaryMultiBulkReply());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,466 +1,6 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class PipelineBlock implements Commands {
|
||||
private Client client;
|
||||
|
||||
public void setClient(Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public void append(String key, String value) {
|
||||
client.append(key, value);
|
||||
}
|
||||
|
||||
public void blpop(String[] args) {
|
||||
client.blpop(args);
|
||||
}
|
||||
|
||||
public void brpop(String[] args) {
|
||||
client.brpop(args);
|
||||
}
|
||||
|
||||
public void decr(String key) {
|
||||
client.decr(key);
|
||||
}
|
||||
|
||||
public void decrBy(String key, long integer) {
|
||||
client.decrBy(key, integer);
|
||||
}
|
||||
|
||||
public void del(String... keys) {
|
||||
client.del(keys);
|
||||
}
|
||||
|
||||
public void echo(String string) {
|
||||
client.echo(string);
|
||||
}
|
||||
|
||||
public void exists(String key) {
|
||||
client.exists(key);
|
||||
}
|
||||
|
||||
public void expire(String key, int seconds) {
|
||||
client.expire(key, seconds);
|
||||
}
|
||||
|
||||
public void expireAt(String key, long unixTime) {
|
||||
client.expireAt(key, unixTime);
|
||||
}
|
||||
|
||||
public void get(String key) {
|
||||
client.get(key);
|
||||
}
|
||||
|
||||
public void getbit(String key, long offset) {
|
||||
client.getbit(key, offset);
|
||||
}
|
||||
|
||||
public void getrange(String key, long startOffset, long endOffset) {
|
||||
client.getrange(key, startOffset, endOffset);
|
||||
}
|
||||
|
||||
public void getSet(String key, String value) {
|
||||
client.getSet(key, value);
|
||||
}
|
||||
|
||||
public void hdel(String key, String field) {
|
||||
client.hdel(key, field);
|
||||
}
|
||||
|
||||
public void hexists(String key, String field) {
|
||||
client.hexists(key, field);
|
||||
}
|
||||
|
||||
public void hget(String key, String field) {
|
||||
client.hget(key, field);
|
||||
}
|
||||
|
||||
public void hgetAll(String key) {
|
||||
client.hgetAll(key);
|
||||
}
|
||||
|
||||
public void hincrBy(String key, String field, long value) {
|
||||
client.hincrBy(key, field, value);
|
||||
}
|
||||
|
||||
public void hkeys(String key) {
|
||||
client.hkeys(key);
|
||||
}
|
||||
|
||||
public void hlen(String key) {
|
||||
client.hlen(key);
|
||||
}
|
||||
|
||||
public void hmget(String key, String... fields) {
|
||||
client.hmget(key, fields);
|
||||
}
|
||||
|
||||
public void hmset(String key, Map<String, String> hash) {
|
||||
client.hmset(key, hash);
|
||||
}
|
||||
|
||||
public void hset(String key, String field, String value) {
|
||||
client.hset(key, field, value);
|
||||
}
|
||||
|
||||
public void hsetnx(String key, String field, String value) {
|
||||
client.hsetnx(key, field, value);
|
||||
}
|
||||
|
||||
public void hvals(String key) {
|
||||
client.hvals(key);
|
||||
}
|
||||
|
||||
public void incr(String key) {
|
||||
client.incr(key);
|
||||
}
|
||||
|
||||
public void incrBy(String key, long integer) {
|
||||
client.incrBy(key, integer);
|
||||
}
|
||||
|
||||
public void keys(String pattern) {
|
||||
client.keys(pattern);
|
||||
}
|
||||
|
||||
public void lindex(String key, int index) {
|
||||
client.lindex(key, index);
|
||||
}
|
||||
|
||||
public void linsert(String key, LIST_POSITION where, String pivot,
|
||||
String value) {
|
||||
client.linsert(key, where, pivot, value);
|
||||
}
|
||||
|
||||
public void llen(String key) {
|
||||
client.llen(key);
|
||||
}
|
||||
|
||||
public void lpop(String key) {
|
||||
client.lpop(key);
|
||||
}
|
||||
|
||||
public void lpush(String key, String string) {
|
||||
client.lpush(key, string);
|
||||
}
|
||||
|
||||
public void lpushx(String key, String string) {
|
||||
client.lpushx(key, string);
|
||||
}
|
||||
|
||||
public void lrange(String key, int start, int end) {
|
||||
client.lrange(key, start, end);
|
||||
}
|
||||
|
||||
public void lrem(String key, int count, String value) {
|
||||
client.lrem(key, count, value);
|
||||
}
|
||||
|
||||
public void lset(String key, int index, String value) {
|
||||
client.lset(key, index, value);
|
||||
}
|
||||
|
||||
public void ltrim(String key, int start, int end) {
|
||||
client.ltrim(key, start, end);
|
||||
}
|
||||
|
||||
public void mget(String... keys) {
|
||||
client.mget(keys);
|
||||
}
|
||||
|
||||
public void move(String key, int dbIndex) {
|
||||
client.move(key, dbIndex);
|
||||
}
|
||||
|
||||
public void mset(String... keysvalues) {
|
||||
client.mset(keysvalues);
|
||||
}
|
||||
|
||||
public void msetnx(String... keysvalues) {
|
||||
client.msetnx(keysvalues);
|
||||
}
|
||||
|
||||
public void persist(String key) {
|
||||
client.persist(key);
|
||||
}
|
||||
|
||||
public void rename(String oldkey, String newkey) {
|
||||
client.rename(oldkey, newkey);
|
||||
}
|
||||
|
||||
public void renamenx(String oldkey, String newkey) {
|
||||
client.renamenx(oldkey, newkey);
|
||||
}
|
||||
|
||||
public void rpop(String key) {
|
||||
client.rpop(key);
|
||||
}
|
||||
|
||||
public void rpoplpush(String srckey, String dstkey) {
|
||||
client.rpoplpush(srckey, dstkey);
|
||||
}
|
||||
|
||||
public void rpush(String key, String string) {
|
||||
client.rpush(key, string);
|
||||
}
|
||||
|
||||
public void rpushx(String key, String string) {
|
||||
client.rpushx(key, string);
|
||||
}
|
||||
|
||||
public void sadd(String key, String member) {
|
||||
client.sadd(key, member);
|
||||
}
|
||||
|
||||
public void scard(String key) {
|
||||
client.scard(key);
|
||||
}
|
||||
|
||||
public void sdiff(String... keys) {
|
||||
client.sdiff(keys);
|
||||
}
|
||||
|
||||
public void sdiffstore(String dstkey, String... keys) {
|
||||
client.sdiffstore(dstkey, keys);
|
||||
}
|
||||
|
||||
public void set(String key, String value) {
|
||||
client.set(key, value);
|
||||
}
|
||||
|
||||
public void setbit(String key, long offset, boolean value) {
|
||||
client.setbit(key, offset, value);
|
||||
}
|
||||
|
||||
public void setex(String key, int seconds, String value) {
|
||||
client.setex(key, seconds, value);
|
||||
}
|
||||
|
||||
public void setnx(String key, String value) {
|
||||
client.setnx(key, value);
|
||||
}
|
||||
|
||||
public void setrange(String key, long offset, String value) {
|
||||
client.setrange(key, offset, value);
|
||||
}
|
||||
|
||||
public void sinter(String... keys) {
|
||||
client.sinter(keys);
|
||||
}
|
||||
|
||||
public void sinterstore(String dstkey, String... keys) {
|
||||
client.sinterstore(dstkey, keys);
|
||||
}
|
||||
|
||||
public void sismember(String key, String member) {
|
||||
client.sismember(key, member);
|
||||
}
|
||||
|
||||
public void smembers(String key) {
|
||||
client.smembers(key);
|
||||
}
|
||||
|
||||
public void smove(String srckey, String dstkey, String member) {
|
||||
client.smove(srckey, dstkey, member);
|
||||
}
|
||||
|
||||
public void sort(String key) {
|
||||
client.sort(key);
|
||||
}
|
||||
|
||||
public void sort(String key, SortingParams sortingParameters) {
|
||||
client.sort(key, sortingParameters);
|
||||
}
|
||||
|
||||
public void sort(String key, SortingParams sortingParameters, String dstkey) {
|
||||
client.sort(key, sortingParameters, dstkey);
|
||||
}
|
||||
|
||||
public void sort(String key, String dstkey) {
|
||||
client.sort(key, dstkey);
|
||||
}
|
||||
|
||||
public void spop(String key) {
|
||||
client.spop(key);
|
||||
}
|
||||
|
||||
public void srandmember(String key) {
|
||||
client.srandmember(key);
|
||||
}
|
||||
|
||||
public void srem(String key, String member) {
|
||||
client.srem(key, member);
|
||||
}
|
||||
|
||||
public void strlen(String key) {
|
||||
client.strlen(key);
|
||||
}
|
||||
|
||||
public void substr(String key, int start, int end) {
|
||||
client.substr(key, start, end);
|
||||
}
|
||||
|
||||
public void sunion(String... keys) {
|
||||
client.sunion(keys);
|
||||
}
|
||||
|
||||
public void sunionstore(String dstkey, String... keys) {
|
||||
client.sunionstore(dstkey, keys);
|
||||
}
|
||||
|
||||
public void ttl(String key) {
|
||||
client.ttl(key);
|
||||
}
|
||||
|
||||
public void type(String key) {
|
||||
client.type(key);
|
||||
}
|
||||
|
||||
public void watch(String... keys) {
|
||||
client.watch(keys);
|
||||
}
|
||||
|
||||
public void zadd(String key, double score, String member) {
|
||||
client.zadd(key, score, member);
|
||||
}
|
||||
|
||||
public void zcard(String key) {
|
||||
client.zcard(key);
|
||||
}
|
||||
|
||||
public void zcount(String key, double min, double max) {
|
||||
client.zcount(key, min, max);
|
||||
}
|
||||
|
||||
public void zincrby(String key, double score, String member) {
|
||||
client.zincrby(key, score, member);
|
||||
}
|
||||
|
||||
public void zinterstore(String dstkey, String... sets) {
|
||||
client.zinterstore(dstkey, sets);
|
||||
}
|
||||
|
||||
public void zinterstore(String dstkey, ZParams params, String... sets) {
|
||||
client.zinterstore(dstkey, params, sets);
|
||||
}
|
||||
|
||||
public void zrange(String key, int start, int end) {
|
||||
client.zrange(key, start, end);
|
||||
}
|
||||
|
||||
public void zrangeByScore(String key, double min, double max) {
|
||||
client.zrangeByScore(key, min, max);
|
||||
}
|
||||
|
||||
public void zrangeByScore(String key, String min, String max) {
|
||||
client.zrangeByScore(key, min, max);
|
||||
}
|
||||
|
||||
public void zrangeByScore(String key, double min, double max, int offset,
|
||||
int count) {
|
||||
client.zrangeByScore(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public void zrangeByScoreWithScores(String key, double min, double max) {
|
||||
client.zrangeByScoreWithScores(key, min, max);
|
||||
}
|
||||
|
||||
public void zrangeByScoreWithScores(String key, double min, double max,
|
||||
int offset, int count) {
|
||||
client.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public void zrangeWithScores(String key, int start, int end) {
|
||||
client.zrangeWithScores(key, start, end);
|
||||
}
|
||||
|
||||
public void zrank(String key, String member) {
|
||||
client.zrank(key, member);
|
||||
}
|
||||
|
||||
public void zrem(String key, String member) {
|
||||
client.zrem(key, member);
|
||||
}
|
||||
|
||||
public void zremrangeByRank(String key, int start, int end) {
|
||||
client.zremrangeByRank(key, start, end);
|
||||
}
|
||||
|
||||
public void zremrangeByScore(String key, double start, double end) {
|
||||
client.zremrangeByScore(key, start, end);
|
||||
}
|
||||
|
||||
public void zrevrange(String key, int start, int end) {
|
||||
client.zrevrange(key, start, end);
|
||||
}
|
||||
|
||||
public void zrevrangeWithScores(String key, int start, int end) {
|
||||
client.zrevrangeWithScores(key, start, end);
|
||||
}
|
||||
|
||||
public void zrevrank(String key, String member) {
|
||||
client.zrevrank(key, member);
|
||||
}
|
||||
|
||||
public void zscore(String key, String member) {
|
||||
client.zscore(key, member);
|
||||
}
|
||||
|
||||
public void zunionstore(String dstkey, String... sets) {
|
||||
client.zunionstore(dstkey, sets);
|
||||
}
|
||||
|
||||
public void zunionstore(String dstkey, ZParams params, String... sets) {
|
||||
client.zunionstore(dstkey, params, sets);
|
||||
}
|
||||
|
||||
public void bgrewriteaof() {
|
||||
client.bgrewriteaof();
|
||||
}
|
||||
|
||||
public void bgsave() {
|
||||
client.bgsave();
|
||||
}
|
||||
|
||||
public void configGet(String pattern) {
|
||||
client.configGet(pattern);
|
||||
}
|
||||
|
||||
public void configSet(String parameter, String value) {
|
||||
client.configSet(parameter, value);
|
||||
}
|
||||
|
||||
public void brpoplpush(String source, String destination, int timeout) {
|
||||
client.brpoplpush(source, destination, timeout);
|
||||
}
|
||||
|
||||
public void configResetStat() {
|
||||
client.configResetStat();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
client.save();
|
||||
}
|
||||
|
||||
public void lastsave() {
|
||||
client.lastsave();
|
||||
}
|
||||
|
||||
public void discard() {
|
||||
client.discard();
|
||||
}
|
||||
|
||||
public void exec() {
|
||||
client.exec();
|
||||
}
|
||||
|
||||
public void multi() {
|
||||
client.multi();
|
||||
}
|
||||
|
||||
public abstract class PipelineBlock extends Pipeline {
|
||||
public abstract void execute();
|
||||
}
|
||||
|
||||
31
src/main/java/redis/clients/jedis/Response.java
Normal file
31
src/main/java/redis/clients/jedis/Response.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
|
||||
public class Response<T> {
|
||||
protected T response = null;
|
||||
private boolean built = false;
|
||||
private Builder<T> builder;
|
||||
|
||||
public Response(Builder<T> b) {
|
||||
this.builder = b;
|
||||
}
|
||||
|
||||
public void set(Object data) {
|
||||
response = builder.build(data);
|
||||
built = true;
|
||||
}
|
||||
|
||||
public T get() {
|
||||
if (!built) {
|
||||
throw new JedisDataException(
|
||||
"Please close pipeline or multi block before calling this method.");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Response " + builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user