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