Issue Details (XML | Word | Printable)

Key: PORTLETSPEC3-22
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: msnicklous
Reporter: julien_viet
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
portletspec3

Use varargs when it is possible

Created: 10/May/13 08:32 AM   Updated: 25/Aug/13 04:37 PM   Resolved: 25/Aug/13 04:37 PM
Component/s: Ideas for JSR 362 Extensions
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Tags:
Participants: andre.hagemeier, julien_viet, msnicklous and Neil Griffin


 Description  « Hide

Some methods of the API uses array based last argument like in BaseURL:

public void setParameter (String name, String[] values);

I suggest we could replace this by a varargs, providing the same signature and improving the usability of the API to:

public void setParameter (String name, String... values);



Neil Griffin added a comment - 14/May/13 04:42 AM

+1 great flexibility


andre.hagemeier added a comment - 31/Jul/13 05:48 PM

+1


msnicklous added a comment - 24/Aug/13 08:59 PM

I can find the following methods where this would be useful:

BaseURL.setParameter (String name, String[] values)
PortletPreferences.setValues(String key, String[] values)
StateAwareResponse.setRenderParameter(String key, String[] values)

did I miss any?

How do you actually document a vararg argument in the javadoc comments? For example, the first line of BaseURL.setParameter reads

Sets the given String array parameter to this URL.

Should we just leave it like that?

"Sets the String vararg ..." sounds weird to me.


msnicklous added a comment - 25/Aug/13 04:37 PM

Changed String[] parameter to String... parameter on the methods BaseURL.setParameter StateAwareResponse.setRenderParameter PortletPreferences.setValues.

I decided to call them multi-valued parameters, as in:

"Sets a multi-valued String parameter for the render request."

Hope this terminology is found to be appropriate.