If no built-in nor custom Converter
for a requested Type T
, an implicit Converter is automatically provided if the following conditions are met:
T
has a Constructor with a String parameter, orT
has a Constructor with a CharSequence parameter, orT
has a static T valueOf(String)
method, orT
has a static T valueOf(CharSequence)
method, orT
has a static T parse(String)
method, orT
has a static T parse(CharSequence)
method, orT
is an Enum
, in which case the Enum#valueOf(Class, String)
is being used.In the original discussion of #248, I only suggested to add he following common support:
The target type T
has a Constructor with a String parameter
the target type T
has a static T valueOf(String)
method,
The above will cover most scenarios and it is straightforward.
The current codebase introduces too many variety and in the spec we need to specify the search order, e.g. Constructor(String)-> Constructor(CharSequence)->valueOf(String).... I feel this complicates the spec without much gain. What do people think on removing the CharSequence support, parse and Enum, while just keep the above two support. Besides, we are providing a convenient method. If anyone wants to use CharSquence, they can provide their own converter. Thoughts?
I raised the above in the config repo (https://github.com/eclipse/microprofile-config/issues/269). You can either comment here or directly on the issue.
Thanks
Emily
--
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile+unsubscribe@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/429d6a05-ab0f-40e4-b5f9-2f60dc40e1d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
T
has a Constructor with a String parameter, orT
has a Constructor with a CharSequence parameter, orT
has a static T valueOf(String)
method, orT
has a static T valueOf(CharSequence)
method, orT
has a static T parse(String)
method, orT
has a static T parse(CharSequence)
method, orT
is an Enum
, in which case the Enum#valueOf(Class, String)
is being used.to be:
T
has a Constructor with a String parameter, orT
has a static T valueOf(String)
method, orT
is an Enum
, in which case the Enum#valueOf(Class, String)
is being used.To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
I am sorting the next MP config release and have a question on one of the changes under the issue #248
Since Config 1.1, we have added the following support under the issue #248
=== Automatic ConvertersIf no built-in nor custom
Converter
for a requested TypeT
, an implicit Converter is automatically provided if the following conditions are met:
- The target type
T
has a Constructor with a String parameter, or- the target type
T
has a Constructor with a CharSequence parameter, or- the target type
T
has astatic T valueOf(String)
method, or- the target type
T
has astatic T valueOf(CharSequence)
method, or- the target type
T
has astatic T parse(String)
method, or- the target type
T
has astatic T parse(CharSequence)
method, or- the target type
T
is anEnum
, in which case theEnum#valueOf(Class, String)
is being used.
In the original discussion of #248, I only suggested to add he following common support:
The target type
T
has a Constructor with a String parameter
the target typeT
has astatic T valueOf(String)
method,
The above will cover most scenarios and it is straightforward.
The current codebase introduces too many variety and in the spec we need to specify the search order, e.g. Constructor(String)-> Constructor(CharSequence)->valueOf(String).... I feel this complicates the spec without much gain. What do people think on removing the CharSequence support, parse and Enum, while just keep the above two support. Besides, we are providing a convenient method. If anyone wants to use CharSquence, they can provide their own converter. Thoughts?
Technically, this last case isn't needed. When an Enum type is created, it automatically gets a T.valueOf method.
Since both LT and you support my suggestion
, if I don't hear any objections by COB today. I'll go ahead to remove the charSequence bits.
Emily
On Friday, December 8, 2017 at 7:34:48 AM UTC, Ladislav Thon wrote:2017-12-08 1:22 GMT+01:00 John D. Ament <john.d...@gmail.com>:Technically, this last case isn't needed. When an Enum type is created, it automatically gets a T.valueOf method.Ah, right, I didn't remember that. My comment above is void, then.LT
--
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/f0d09c83-e171-4be7-a20e-f82a93848fac%40googlegroups.com.
Dne 8. 12. 2017 11:06 napsal uživatel "'Emily Jiang' via Eclipse MicroProfile" <microp...@googlegroups.com>:Since both LT and you support my suggestionI specifically and intentionally abstained from expressing agreement or disagreement, I just said that I understand the desire :-) In fact, my personal opinion on API design is that breaking compatibility is universally bad and should be avoided unless very good arguments are presented. Whether this is the case or not, I don't feel qualified to decide, as I'm mostly a lurker here and don't really know the MP community.LT
, if I don't hear any objections by COB today. I'll go ahead to remove the charSequence bits.--
Emily
On Friday, December 8, 2017 at 7:34:48 AM UTC, Ladislav Thon wrote:2017-12-08 1:22 GMT+01:00 John D. Ament <john.d...@gmail.com>:Technically, this last case isn't needed. When an Enum type is created, it automatically gets a T.valueOf method.Ah, right, I didn't remember that. My comment above is void, then.LT
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/6f15242e-6bad-4df5-ac3f-bfe1aa53aba3%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/CANgkmLCkGdZnDz3XS7%2BsnnC_XbpLNThuiH%3Dtrfz9RP57CfytPw%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/6f15242e-6bad-4df5-ac3f-bfe1aa53aba3%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/a0850bfe-b50e-48b3-a26b-f270dc229711%40googlegroups.com.
Alasdair
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile+unsubscribe@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/a0850bfe-b50e-48b3-a26b-f270dc229711%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/microprofile/TkqdvNqwLkA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to microprofile+unsubscribe@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/13F18887-C429-4C9C-81C8-D1F3DAD623B6%40gmail.com.
Alasdair
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/a0850bfe-b50e-48b3-a26b-f270dc229711%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/microprofile/TkqdvNqwLkA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to microprofile...@googlegroups.com.
To post to this group, send email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/13F18887-C429-4C9C-81C8-D1F3DAD623B6%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/d0b320da-9e1c-47c0-8fbe-31b990e850ae%40googlegroups.com.
@Arjan: yes, thought about it as well. But for a real converter spec you would need both directions String -> T and T -> StringIn Config we only need String -> T.There are quite a few other areas which could benefit, e.g. JSF. But not sure if we get a chance to start yet another JSR ;)
It's not about symmetricity. It is about having simple, concise and *consistent* rules which are easy to grasp.
We do not want to have our users need to know which combination of name + parameter is valid.
It should be kind of self-explaining.
--
You received this message because you are subscribed to a topic in the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/microprofile/TkqdvNqwLkA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to microprofile+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/6161aaca-00a9-4c7a-966d-58945b3f6923%40googlegroups.com.
> In the original discussion of #248, I only suggested to add he following common support:
> The target type T
has a Constructor with a String parameter
> the target type T
has a static T valueOf(String)
method,
To unsubscribe from this group and all its topics, send an email to microprofile...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/6161aaca-00a9-4c7a-966d-58945b3f6923%40googlegroups.com.
The current codebase introduces too many variety and in the spec we need to
specify the search order, e.g. Constructor(String)-> Constructor(CharSequence)->valueOf(String).... I feel this complicates the spec without much
gain. What do people think on removing the CharSequence support, parse
and Enum, while just keep the above two support. Besides, we are providing a convenient method. If anyone wants
to use CharSquence, they can provide their own converter.
Is the above clear?
I raised the above in the config repo (https://github.com/eclipse/microprofile-config/issues/269). You can either comment here or directly on the issue.
Besides, only Alsadair suggested to add one more parse for CharSequence support. I did not see anyone else challenged me.
You listed some random classes. As they are 3rd library, if you want to use them as config value, which I have not thought of a use case for this. One of the solution is to provide a converter. By the way, can you list when and how it is used for config types? How many config library support what the 6 combination of converters?
Emily
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/4e14e712-64b7-4c70-ba27-cae3c1e247c8%40googlegroups.com.