-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArgsBuilder now collects all arguments and returns
GlideString[]
Restored large value tests
- Loading branch information
1 parent
218af8f
commit 7fba7ef
Showing
6 changed files
with
156 additions
and
176 deletions.
There are no files selected for viewing
25 changes: 14 additions & 11 deletions
25
java/client/src/main/java/glide/api/models/ArgsBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,40 @@ | ||
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.api.models; | ||
|
||
import com.google.protobuf.ByteString; | ||
import redis_request.RedisRequestOuterClass.Command.ArgsArray; | ||
import java.util.ArrayList; | ||
|
||
// TODO docs for the god of docs | ||
/** | ||
* Helper class for collecting arbitrary type of arguments and stores them as an array of | ||
* GlideString | ||
*/ | ||
public class ArgsBuilder { | ||
ArgsArray.Builder commandArgs = null; | ||
ArrayList<GlideString> argumentsList = null; | ||
|
||
public ArgsBuilder() { | ||
commandArgs = ArgsArray.newBuilder(); | ||
argumentsList = new ArrayList<>(); | ||
} | ||
|
||
public <ArgType> ArgsBuilder add(ArgType[] args) { | ||
for (ArgType arg : args) { | ||
commandArgs.addArgs(ByteString.copyFrom(GlideString.of(arg).getBytes())); | ||
argumentsList.add(GlideString.of(arg)); | ||
} | ||
|
||
return this; | ||
} | ||
|
||
public <ArgType> ArgsBuilder add(ArgType arg) { | ||
commandArgs.addArgs(ByteString.copyFrom(GlideString.of(arg).getBytes())); | ||
argumentsList.add(GlideString.of(arg)); | ||
return this; | ||
} | ||
|
||
public <ArgType> ArgsBuilder add(String[] args) { | ||
public ArgsBuilder add(String[] args) { | ||
for (String arg : args) { | ||
commandArgs.addArgs(ByteString.copyFromUtf8(arg)); | ||
argumentsList.add(GlideString.of(arg)); | ||
} | ||
return this; | ||
} | ||
|
||
public ArgsArray build() { | ||
return commandArgs.build(); | ||
public GlideString[] toArray() { | ||
return argumentsList.toArray(new GlideString[0]); | ||
} | ||
} |
Oops, something went wrong.