Extend RequestParameter with getters that supports default values
pk-work opened this issue · 2 comments
pk-work commented
If you have e.g. a query parameter that is optional and not part of the request, the RequestValidator will create a new RequestParameterImpl(null) and stores it in the ValidatedRequest.
If I now want to access the value I have always to do a null check:
RequestParameter myList = validatedRequest.getQuery().get("myList");
List<String> list = myList.isNull() ? List.of() : myList .getJsonArray().getList();
I'd like to have convenience methods, like #getJsonArray(JsonArray default)
RequestParameter myList = validatedRequest.getQuery().get("myList");
List<String> list = myList.getJsonArray(new JsonArray()).getList();
What do you think?
thced commented
Maybe support Supplier, for lazy behavior?
CheesyBoy123 commented