|
1 | 1 | package redis.clients.jedis;
|
2 | 2 |
|
3 | 3 | import java.util.ArrayList;
|
| 4 | +import java.util.Arrays; |
4 | 5 | import java.util.Collection;
|
5 | 6 | import java.util.Iterator;
|
6 | 7 |
|
@@ -29,19 +30,50 @@ public ProtocolCommand getCommand() {
|
29 | 30 | return (ProtocolCommand) args.get(0);
|
30 | 31 | }
|
31 | 32 |
|
| 33 | + public CommandArguments add(Rawable arg) { |
| 34 | + args.add(arg); |
| 35 | + return this; |
| 36 | + } |
| 37 | + |
| 38 | + public CommandArguments add(byte[] arg) { |
| 39 | + return add(RawableFactory.from(arg)); |
| 40 | + } |
| 41 | + |
| 42 | + public CommandArguments add(boolean arg) { |
| 43 | + return add(RawableFactory.from(arg)); |
| 44 | + } |
| 45 | + |
| 46 | + public CommandArguments add(int arg) { |
| 47 | + return add(RawableFactory.from(arg)); |
| 48 | + } |
| 49 | + |
| 50 | + public CommandArguments add(long arg) { |
| 51 | + return add(RawableFactory.from(arg)); |
| 52 | + } |
| 53 | + |
| 54 | + public CommandArguments add(double arg) { |
| 55 | + return add(RawableFactory.from(arg)); |
| 56 | + } |
| 57 | + |
| 58 | + public CommandArguments add(String arg) { |
| 59 | + return add(RawableFactory.from(arg)); |
| 60 | + } |
| 61 | + |
32 | 62 | public CommandArguments add(Object arg) {
|
33 | 63 | if (arg == null) {
|
34 | 64 | throw new IllegalArgumentException("null is not a valid argument.");
|
35 | 65 | } else if (arg instanceof Rawable) {
|
36 | 66 | args.add((Rawable) arg);
|
37 | 67 | } else if (arg instanceof byte[]) {
|
38 | 68 | args.add(RawableFactory.from((byte[]) arg));
|
| 69 | + } else if (arg instanceof Boolean) { |
| 70 | + args.add(RawableFactory.from((Boolean) arg)); |
39 | 71 | } else if (arg instanceof Integer) {
|
40 | 72 | args.add(RawableFactory.from((Integer) arg));
|
| 73 | + } else if (arg instanceof Long) { |
| 74 | + args.add(RawableFactory.from((Long) arg)); |
41 | 75 | } else if (arg instanceof Double) {
|
42 | 76 | args.add(RawableFactory.from((Double) arg));
|
43 |
| - } else if (arg instanceof Boolean) { |
44 |
| - args.add(RawableFactory.from((Boolean) arg ? 1 : 0)); |
45 | 77 | } else if (arg instanceof float[]) {
|
46 | 78 | args.add(RawableFactory.from(RediSearchUtil.toByteArray((float[]) arg)));
|
47 | 79 | } else if (arg instanceof String) {
|
@@ -87,14 +119,12 @@ public CommandArguments key(Object key) {
|
87 | 119 | }
|
88 | 120 |
|
89 | 121 | public final CommandArguments keys(Object... keys) {
|
90 |
| - for (Object key : keys) { |
91 |
| - key(key); |
92 |
| - } |
| 122 | + Arrays.stream(keys).forEach(this::key); |
93 | 123 | return this;
|
94 | 124 | }
|
95 | 125 |
|
96 | 126 | public final CommandArguments keys(Collection keys) {
|
97 |
| - keys.forEach(key -> key(key)); |
| 127 | + keys.forEach(this::key); |
98 | 128 | return this;
|
99 | 129 | }
|
100 | 130 |
|
|
0 commit comments