Skip to content

Commit

Permalink
Added Converter Resolution explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Sep 10, 2013
1 parent f7ce125 commit c31abf8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion convert/README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,17 @@ Additionally, you may directly inject typed converters:
@Inject Converter<SOURCE,TARGET> converter;
----
====
Converter Resolution::
By default, the Converter API will automatically attempt to find the assigned converter by doing the following checks:

Custom converters::
- Check if a custom converter was registered (see next section);
* If no custom converter is found, the following checks are made:
** Given a source type and a target type, check if the target type has a constructor with only the source type as a parameter. eg: public static MyClass valueOf(String str){...}
** Given a source type and a target type check if the target type has a static method valueOf receiving the source type as a parameter. eg: public static MyClass valueOf(String str){...}
- If converter resolution fails, a ConverterNotFoundException is thrown.

====
Custom converters::
The convert API can be extended to register converters for types that are not supported by default. This is a two
step process involving creation of a new type that extends from `Converter`, and of a `ConverterGenerator`.
These custom converters will be made automatically available to other addons that depend on the convert addon.
Expand Down

0 comments on commit c31abf8

Please sign in to comment.