[
https://issues.apache.org/jira/browse/SOLR-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12478895
]
J.J. Larrea commented on SOLR-183:
----------------------------------
Er, sorry to be contrary, but to me it seems a bit excessive to go through so
many hoops to support the getXXX(param, default) methods, which contradicts
the very nature of the class, which is to require parameters.
If one wanted to stick with Hoss' preference for a decorator, and kept the
getXXX(param, default) method signatures defined in SolrParams, one could argue
that it would make sense to make those methods simply return SolrExceptions, on
the assumption that requires.getInt(param, 0) must be a programmer error. That
is of course automatically achieved if only get and getParams are overridden,
as was proposed earlier. It's not so terrible to maintain parallel params and
requires references to the same underlying param list.
But if one is going to bother adding real implementations for every method
signature in SolrParams, then why not simply dispense with the decorator and
add getRequiredXXX(param) methods with default implementations directly to
SolrParams, e.g.
getRequiredParam(String param)
getRequiredParams(String param)
getRequiredBool(String param)
getRequiredFieldBool(String field, String param)
... etc.
That seems simpler, straightforward, and unambiguous.
> add getRequiredParameter() to SolrParams
> ----------------------------------------
>
> Key: SOLR-183
> URL: https://issues.apache.org/jira/browse/SOLR-183
> Project: Solr
> Issue Type: Wish
> Reporter: Ryan McKinley
> Priority: Trivial
> Attachments: SOLR-183-required-param.patch,
> SOLR-183-required-param.patch
>
>
> I find myself including this with every patch, so i'll just separate it out.
> This simply adds a utilty function to SolrParams that throws a 400 if the
> parameter is missing:
> /** returns the value of the param, or throws a 400 exception if missing */
> public String getRequiredParameter(String param) throws SolrException {
> String val = get(param);
> if( val == null ) {
> throw new SolrException( 400, "Missing parameter: "+param );
> }
> return val;
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.