Skip to content

Commit

Permalink
Java: Add non-null tags to missing commands (#123) (valkey-io#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
SanHalacogluImproving authored Mar 4, 2024
1 parent 10186a3 commit 0a60159
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
8 changes: 4 additions & 4 deletions java/client/src/main/java/glide/api/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,24 +404,24 @@ public CompletableFuture<String[]> rpopCount(@NonNull String key, long count) {
}

@Override
public CompletableFuture<Long> sadd(String key, String[] members) {
public CompletableFuture<Long> sadd(@NonNull String key, @NonNull String[] members) {
String[] arguments = ArrayUtils.addFirst(members, key);
return commandManager.submitNewCommand(SAdd, arguments, this::handleLongResponse);
}

@Override
public CompletableFuture<Long> srem(String key, String[] members) {
public CompletableFuture<Long> srem(@NonNull String key, @NonNull String[] members) {
String[] arguments = ArrayUtils.addFirst(members, key);
return commandManager.submitNewCommand(SRem, arguments, this::handleLongResponse);
}

@Override
public CompletableFuture<Set<String>> smembers(String key) {
public CompletableFuture<Set<String>> smembers(@NonNull String key) {
return commandManager.submitNewCommand(SMembers, new String[] {key}, this::handleSetResponse);
}

@Override
public CompletableFuture<Long> scard(String key) {
public CompletableFuture<Long> scard(@NonNull String key) {
return commandManager.submitNewCommand(SCard, new String[] {key}, this::handleLongResponse);
}

Expand Down
2 changes: 1 addition & 1 deletion java/client/src/main/java/glide/api/RedisClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public CompletableFuture<Object> customCommand(@NonNull String[] args) {
}

@Override
public CompletableFuture<Object[]> exec(Transaction transaction) {
public CompletableFuture<Object[]> exec(@NonNull Transaction transaction) {
return commandManager.submitNewCommand(transaction, this::handleArrayOrNullResponse);
}

Expand Down
7 changes: 4 additions & 3 deletions java/client/src/main/java/glide/api/RedisClusterClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public CompletableFuture<ClusterValue<Object>> customCommand(@NonNull String[] a
}

@Override
public CompletableFuture<ClusterValue<Object>> customCommand(String[] args, Route route) {
public CompletableFuture<ClusterValue<Object>> customCommand(
@NonNull String[] args, @NonNull Route route) {
return commandManager.submitNewCommand(
CustomCommand, args, route, response -> handleCustomCommandResponse(route, response));
}
Expand All @@ -69,14 +70,14 @@ protected ClusterValue<Object> handleCustomCommandResponse(Route route, Response
}

@Override
public CompletableFuture<Object[]> exec(ClusterTransaction transaction) {
public CompletableFuture<Object[]> exec(@NonNull ClusterTransaction transaction) {
return commandManager.submitNewCommand(
transaction, Optional.empty(), this::handleArrayOrNullResponse);
}

@Override
public CompletableFuture<ClusterValue<Object>[]> exec(
ClusterTransaction transaction, Route route) {
@NonNull ClusterTransaction transaction, Route route) {
return commandManager
.submitNewCommand(transaction, Optional.ofNullable(route), this::handleArrayOrNullResponse)
.thenApply(
Expand Down
24 changes: 12 additions & 12 deletions java/client/src/main/java/glide/api/models/BaseTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public T ping() {
* @param msg The ping argument that will be returned.
* @return A response from Redis with a <code>String</code>.
*/
public T ping(String msg) {
public T ping(@NonNull String msg) {
ArgsArray commandArgs = buildArgs(msg);

protobufTransaction.addCommands(buildCommand(Ping, commandArgs));
Expand All @@ -144,7 +144,7 @@ public T info() {
* @return Response from Redis with a <code>String</code> containing the requested {@link
* Section}s.
*/
public T info(InfoOptions options) {
public T info(@NonNull InfoOptions options) {
ArgsArray commandArgs = buildArgs(options.toArgs());

protobufTransaction.addCommands(buildCommand(Info, commandArgs));
Expand All @@ -159,7 +159,7 @@ public T info(InfoOptions options) {
* @param keys The keys we wanted to remove.
* @return Command Response - The number of keys that were removed.
*/
public T del(String[] keys) {
public T del(@NonNull String[] keys) {
ArgsArray commandArgs = buildArgs(keys);

protobufTransaction.addCommands(buildCommand(Del, commandArgs));
Expand All @@ -174,7 +174,7 @@ public T del(String[] keys) {
* @return Response from Redis. <code>key</code> exists, returns the <code>value</code> of <code>
* key</code> as a String. Otherwise, return <code>null</code>.
*/
public T get(String key) {
public T get(@NonNull String key) {
ArgsArray commandArgs = buildArgs(key);

protobufTransaction.addCommands(buildCommand(GetString, commandArgs));
Expand All @@ -189,7 +189,7 @@ public T get(String key) {
* @param value The value to store with the given <code>key</code>.
* @return Response from Redis.
*/
public T set(String key, String value) {
public T set(@NonNull String key, @NonNull String value) {
ArgsArray commandArgs = buildArgs(key, value);

protobufTransaction.addCommands(buildCommand(SetString, commandArgs));
Expand All @@ -209,7 +209,7 @@ public T set(String key, String value) {
* {@link ConditionalSet#ONLY_IF_DOES_NOT_EXIST} conditions, return <code>null</code>.
* Otherwise, return <code>OK</code>.
*/
public T set(String key, String value, SetOptions options) {
public T set(@NonNull String key, @NonNull String value, @NonNull SetOptions options) {
ArgsArray commandArgs =
buildArgs(ArrayUtils.addAll(new String[] {key, value}, options.toArgs()));

Expand Down Expand Up @@ -659,7 +659,7 @@ public T rpopCount(@NonNull String key, long count) {
* @remarks If <code>key</code> does not exist, a new set is created before adding <code>members
* </code>.
*/
public T sadd(String key, String[] members) {
public T sadd(@NonNull String key, @NonNull String[] members) {
ArgsArray commandArgs = buildArgs(ArrayUtils.addFirst(members, key));

protobufTransaction.addCommands(buildCommand(SAdd, commandArgs));
Expand All @@ -678,7 +678,7 @@ public T sadd(String key, String[] members) {
* @remarks If <code>key</code> does not exist, it is treated as an empty set and this command
* returns 0.
*/
public T srem(String key, String[] members) {
public T srem(@NonNull String key, @NonNull String[] members) {
ArgsArray commandArgs = buildArgs(ArrayUtils.addFirst(members, key));

protobufTransaction.addCommands(buildCommand(SRem, commandArgs));
Expand All @@ -693,7 +693,7 @@ public T srem(String key, String[] members) {
* @return Command Response - A <code>Set</code> of all members of the set.
* @remarks If <code>key</code> does not exist an empty set will be returned.
*/
public T smembers(String key) {
public T smembers(@NonNull String key) {
ArgsArray commandArgs = buildArgs(key);

protobufTransaction.addCommands(buildCommand(SMembers, commandArgs));
Expand All @@ -708,7 +708,7 @@ public T smembers(String key) {
* @return Command Response - The cardinality (number of elements) of the set, or 0 if the key
* does not exist.
*/
public T scard(String key) {
public T scard(@NonNull String key) {
ArgsArray commandArgs = buildArgs(key);

protobufTransaction.addCommands(buildCommand(SCard, commandArgs));
Expand All @@ -723,7 +723,7 @@ public T scard(String key) {
* @return Command Response - The number of keys that exist. If the same existing key is mentioned
* in <code>keys</code> multiple times, it will be counted multiple times.
*/
public T exists(String[] keys) {
public T exists(@NonNull String[] keys) {
ArgsArray commandArgs = buildArgs(keys);

protobufTransaction.addCommands(buildCommand(Exists, commandArgs));
Expand All @@ -740,7 +740,7 @@ public T exists(String[] keys) {
* @param keys The list of keys to unlink.
* @return Command Response - The number of <code>keys</code> that were unlinked.
*/
public T unlink(String[] keys) {
public T unlink(@NonNull String[] keys) {
ArgsArray commandArgs = buildArgs(keys);

protobufTransaction.addCommands(buildCommand(Unlink, commandArgs));
Expand Down

0 comments on commit 0a60159

Please sign in to comment.