rest icon indicating copy to clipboard operation
rest copied to clipboard

Clarification: Priorities of parameter conversion rules

Open mkarg opened this issue 2 years ago • 6 comments

In the specification we do list different ways of converting a String to a parameter. A user recently asked, if the sequence mentioned in the spec is actually a mandatory priority? Actually it is necessary to know the sequence of priorities in case multple rules do match a parameter, e. g. there is a publis String constructor and a valueOf-Method and a param converter.

As it is not explicitly mentioned by the spec, we should add a note that the sequence is mandatory and re-order it like this:

  1. ParamConverter -- it makes no sense to explicitly register these, if not preferring it over all other rules.
  2. fromString, valueOf -- it makes no sense to have these seldomly found methods, if not preferring it to constructors.
  3. String-consuming constructor -- as this is the most simple attempt, it should be used only if no more complex solution exists.

mkarg avatar May 16 '22 11:05 mkarg

Not directly answering the question, but I still would love to have these concerns split off to a separate converter spec. We're seeing similar issues and questions in e.g. Jakarta Faces.

arjantijms avatar May 16 '22 11:05 arjantijms

+1 for supporting such a spec once it is there, but for the time being readers of the spec need an unambiguous answer on the originl question

mkarg avatar May 20 '22 22:05 mkarg

@jansupol @andymc12 @chkal @spericas Is this core proposal OK for you then please briefly confirm, so I will turn it into a MR. Thanks.

mkarg avatar May 28 '22 14:05 mkarg

I'm fine with your proposal of enforcing the order as currently listed in the spec. :+1:

chkal avatar May 29 '22 10:05 chkal

I was under the impression that the Spec already defines the order in Section 3.2. String consuming argument has priority to fromString, valueOf. I am not convinced that the change of order - another incompatibility - would help the users.

jansupol avatar Jun 14 '22 20:06 jansupol

The spec lists the types that are supported in connection with those "injection" points. It sort of establishes an order for how the conversion should proceed (should more than one alternative is available), but it is not very explicit. I'm fine with the proposal.

spericas avatar Jun 15 '22 13:06 spericas