Skip to content

Commit

Permalink
Converters - Add some shortcuts for JDK classes
Browse files Browse the repository at this point in the history
It seems counter productive to throw so many NoSuchMethodExceptions for
these common uses cases.
  • Loading branch information
gsmet committed Jan 7, 2025
1 parent 2bcff37 commit d0478b2
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,14 @@ static <T> Converter<T> getConverter(Class<? extends T> clazz) {
return new HyphenateEnumConverter(clazz);
}

// some shortcuts for common used classes
if ("java.io.File".equals(clazz.getName())) {
return getConverterFromConstructor(clazz, String.class);
}
if ("java.net.URI".equals(clazz.getName())) {
return getConverterFromConstructor(clazz, String.class);
}

// implicit converters required by the specification
Converter<T> converter = getConverterFromStaticMethod(clazz, "of", String.class);
if (converter == null) {
Expand Down

0 comments on commit d0478b2

Please sign in to comment.