MicroProfile Config - remove built-in converters and promote implicit converters

37 views
Skip to first unread message

Emily Jiang

unread,
Mar 21, 2018, 7:27:14 PM3/21/18
to Eclipse MicroProfile

Since we have the notion of the implicit converter, it takes all classes with the following criteria:

If no explicit Converter and no built-in Converter could be found for a certain type,

  • The target type {@code T} has a public Constructor with a String parameter, or
  • the target type {@code T} has a {@code public static T valueOf(String)} method, or
  • the target type {@code T} has a {@code public static T parse(CharSequence)} method

With this, all built in converters are not required to be listed as they either have valueOf or a constructor taking a String parameter.

However, to improve the performance (as valueOf has a cache facility while the constructor does not have) and take into the new JVM class method naming scheme, I suggest we update the search sequence for the implicit converter.

  • the target type {@code T} has a {@code public static T of(String)} method
  • the target type {@code T} has a {@code public static T valueOf(String)} method, or
  • The target type {@code T} has a public Constructor with a String parameter, or
  • the target type {@code T} has a {@code public static T parse(CharSequence)} method

With this change, we can remove the big list of the default converters and all of them falls under implicit converters. This will reduce the burden to keep on adding built in converters in the future. Any comments?



Emily

Bob McWhirter

unread,
Mar 21, 2018, 7:42:58 PM3/21/18
to microp...@googlegroups.com
+1



--
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 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/d2fbaa26-d91a-4878-824d-9a54a2934692%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ondro Mihályi

unread,
Mar 23, 2018, 2:58:54 AM3/23/18
to Eclipse MicroProfile
+1

--Ondro

Emily Jiang

unread,
Mar 23, 2018, 7:27:39 PM3/23/18
to Eclipse MicroProfile
Thank you Bob and Ondro for your support! I'll prepare a PR soon.

Thanks
Emily

On Friday, March 23, 2018 at 6:58:54 AM UTC, Ondro Mihályi wrote:
+1

--Ondro

John D. Ament

unread,
Apr 23, 2018, 1:17:15 PM4/23/18
to Eclipse MicroProfile
Did you ever raise a PR for this?  I'm assuming that you're leaving in the non-trivial built in converters, right? (E.g. Class)

Emily Jiang

unread,
Apr 23, 2018, 4:28:14 PM4/23/18
to MicroProfile
yes, Class was left. I think you viewed the PR. You can look at the current master branch, which has the latest changes.

Thanks
Emily

--
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/AOt7fVSqxcc/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.

For more options, visit https://groups.google.com/d/optout.



--
Thanks
Emily
=================
Emily Jiang
eji...@apache.org
Reply all
Reply to author
Forward
0 new messages