Accept single values for jsonrpc requests where a list is expected

This commit is contained in:
AsamK 2021-08-24 12:37:40 +02:00
parent 6c3106db5d
commit 8c661c23be

View file

@ -40,6 +40,7 @@ public interface JsonRpcLocalCommand extends JsonRpcCommand<Map<String, Object>>
super(attrs);
}
@Override
public <T> T get(String dest) {
final T value = super.get(dest);
if (value != null) {
@ -52,10 +53,14 @@ public interface JsonRpcLocalCommand extends JsonRpcCommand<Map<String, Object>>
@Override
public <E> List<E> getList(final String dest) {
try {
final List<E> value = super.getList(dest);
if (value != null) {
return value;
}
} catch (ClassCastException e) {
return List.of(this.<E>get(dest));
}
return super.getList(dest + "s");
}