DATAREDIS-822 - Consider argument range in RedisCommand min/max arguments specification.
We now consider max argument specifications as upper bound and no longer as the exact number of required arguments. Original pull request: #335.
This commit is contained in:
@@ -28,6 +28,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @author Ninad Divadkar
|
||||
* @author Mark Paluch
|
||||
* @since 1.3
|
||||
* @see Redis command list:
|
||||
* https://github.com/antirez/redis/blob/93e7a130fc9594e41ccfc996b5eca7626ae5356a/src/redis.c#L119
|
||||
@@ -279,10 +280,10 @@ public enum RedisCommand {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@literal true} if an exact number of arguments is expected
|
||||
* @return {@literal true} if an exact number of arguments is expected.
|
||||
*/
|
||||
public boolean requiresExactNumberOfArguments() {
|
||||
return maxArgs >= 0;
|
||||
return maxArgs == 0 || minArgs == maxArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,6 +346,11 @@ public enum RedisCommand {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("%s command requires at least %s arguments.", this.name(), this.minArgs));
|
||||
}
|
||||
|
||||
if (maxArgs != 0 && nrArguments > maxArgs) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("%s command requires at most %s arguments.", this.name(), this.maxArgs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user