{"action":"created","comment":{"url":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/comments/190542917","pull_request_review_id":122938371,"id":190542917,"diff_hunk":"@@ -6,32 +6,81 @@\n import org.w3c.dom.Node;\n \n import javax.xml.bind.JAXBContext;\n-import javax.xml.bind.JAXBElement;\n import javax.xml.bind.annotation.adapters.XmlAdapter;\n import javax.xml.namespace.QName;\n import javax.xml.parsers.DocumentBuilder;\n import javax.xml.parsers.DocumentBuilderFactory;\n+import java.util.Arrays;\n+import java.util.Collection;\n \n import static java.lang.String.format;\n \n-public class SimpleElementAdapter extends XmlAdapter<Element, SimpleElement> {\n+public class ExtensionElementAdapter extends XmlAdapter<Element, ExtensionElement> implements ElementQNameFactory {\n+\n+    private static final Class[] ADAPTED_TYPES = {StructuredElement.class, SimpleElement.class, AnyElement.class};\n \n     private DocumentBuilder builder;\n     private JAXBContext context;\n+    private Collection<ExtensionElementConverter> possibleConversions;\n \n     @Override\n-    public Element marshal(SimpleElement simpleElement) throws Exception {\n-        if (simpleElement == null) {\n+    public Element marshal(ExtensionElement extensionElement) throws Exception {\n+        if (extensionElement == null) {\n             return null;\n         }\n \n-        Element element = createElement(simpleElement);\n-        addAttributes(element, simpleElement);\n+        for (ExtensionElementConverter converter : possibleConversions()) {\n+            if (converter.canConvert(extensionElement)) {\n+                return convertElement(extensionElement, converter);\n+            }\n+        }\n+\n+        throw new IllegalArgumentException(\"Cannot handle Additional element: \" + extensionElement);\n+    }\n+\n+    private Collection<ExtensionElementConverter> possibleConversions() {\n+        if(possibleConversions == null) {\n+            possibleConversions = Arrays.asList(\n+                new SimpleElementExtensionConverter(this),\n+                new StructuredElementExtensionConverter(this),\n+                new AnyElementExtensionConverter(this));\n+        }\n+        return possibleConversions;\n+    }\n+\n+    private Element convertElement(ExtensionElement extensionElement, ExtensionElementConverter converter) throws Exception {","path":"src/main/java/fr/vidal/oss/jaxb/atom/core/ExtensionElementAdapter.java","position":59,"original_position":52,"commit_id":"7f82f2840b8dccb0e76f9a89478fa6da0465756e","original_commit_id":"628de73023102242835c9028691db02df5b20e8e","user":{"login":"fhiegel","id":7289459,"avatar_url":"https://avatars3.githubusercontent.com/u/7289459?v=4","gravatar_id":"","url":"https://api.github.com/users/fhiegel","html_url":"https://github.com/fhiegel","followers_url":"https://api.github.com/users/fhiegel/followers","following_url":"https://api.github.com/users/fhiegel/following{/other_user}","gists_url":"https://api.github.com/users/fhiegel/gists{/gist_id}","starred_url":"https://api.github.com/users/fhiegel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhiegel/subscriptions","organizations_url":"https://api.github.com/users/fhiegel/orgs","repos_url":"https://api.github.com/users/fhiegel/repos","events_url":"https://api.github.com/users/fhiegel/events{/privacy}","received_events_url":"https://api.github.com/users/fhiegel/received_events","type":"User","site_admin":false},"body":"Alors : oui, ce serait carrément plus simple, d'autant qu'un élément ne possède qu'un seul converter. On n'aurait plus besoin d'avoir une strategy dans l'adapter avec JAXB, ce qui rendrait le code davantage accessible.\r\n\r\nPar contre ; je ne suis pas certain que ce soit de la responsabilité des `ExtensionElement` de savoir comment se convertir en élement compatible JAXB.\r\n\r\nJe suis partant pour en discuter de vive voix quand tu as un peu de temps :)","created_at":"2018-05-24T10:47:35Z","updated_at":"2018-05-24T10:47:36Z","html_url":"https://github.com/vidal-community/atom-jaxb/pull/26#discussion_r190542917","pull_request_url":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/26","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/comments/190542917"},"html":{"href":"https://github.com/vidal-community/atom-jaxb/pull/26#discussion_r190542917"},"pull_request":{"href":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/26"}},"in_reply_to_id":190493154},"pull_request":{"url":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/26","id":185971026,"html_url":"https://github.com/vidal-community/atom-jaxb/pull/26","diff_url":"https://github.com/vidal-community/atom-jaxb/pull/26.diff","patch_url":"https://github.com/vidal-community/atom-jaxb/pull/26.patch","issue_url":"https://api.github.com/repos/vidal-community/atom-jaxb/issues/26","number":26,"state":"open","locked":false,"title":"RFC-4287: Implements 6.4.2: Structured Extension Elements","user":{"login":"fhiegel","id":7289459,"avatar_url":"https://avatars3.githubusercontent.com/u/7289459?v=4","gravatar_id":"","url":"https://api.github.com/users/fhiegel","html_url":"https://github.com/fhiegel","followers_url":"https://api.github.com/users/fhiegel/followers","following_url":"https://api.github.com/users/fhiegel/following{/other_user}","gists_url":"https://api.github.com/users/fhiegel/gists{/gist_id}","starred_url":"https://api.github.com/users/fhiegel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhiegel/subscriptions","organizations_url":"https://api.github.com/users/fhiegel/orgs","repos_url":"https://api.github.com/users/fhiegel/repos","events_url":"https://api.github.com/users/fhiegel/events{/privacy}","received_events_url":"https://api.github.com/users/fhiegel/received_events","type":"User","site_admin":false},"body":"Correct #25","created_at":"2018-05-04T12:35:14Z","updated_at":"2018-05-24T10:47:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2290a15548dcd82d6ff32983b17689bd3d63625c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":394339072,"url":"https://api.github.com/repos/vidal-community/atom-jaxb/labels/wip","name":"wip","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/26/commits","review_comments_url":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/26/comments","review_comment_url":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vidal-community/atom-jaxb/issues/26/comments","statuses_url":"https://api.github.com/repos/vidal-community/atom-jaxb/statuses/7f82f2840b8dccb0e76f9a89478fa6da0465756e","head":{"label":"vidal-community:RFC-4287.structured-extension-elements","ref":"RFC-4287.structured-extension-elements","sha":"7f82f2840b8dccb0e76f9a89478fa6da0465756e","user":{"login":"vidal-community","id":12967061,"avatar_url":"https://avatars2.githubusercontent.com/u/12967061?v=4","gravatar_id":"","url":"https://api.github.com/users/vidal-community","html_url":"https://github.com/vidal-community","followers_url":"https://api.github.com/users/vidal-community/followers","following_url":"https://api.github.com/users/vidal-community/following{/other_user}","gists_url":"https://api.github.com/users/vidal-community/gists{/gist_id}","starred_url":"https://api.github.com/users/vidal-community/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vidal-community/subscriptions","organizations_url":"https://api.github.com/users/vidal-community/orgs","repos_url":"https://api.github.com/users/vidal-community/repos","events_url":"https://api.github.com/users/vidal-community/events{/privacy}","received_events_url":"https://api.github.com/users/vidal-community/received_events","type":"Organization","site_admin":false},"repo":{"id":29817265,"name":"atom-jaxb","full_name":"vidal-community/atom-jaxb","owner":{"login":"vidal-community","id":12967061,"avatar_url":"https://avatars2.githubusercontent.com/u/12967061?v=4","gravatar_id":"","url":"https://api.github.com/users/vidal-community","html_url":"https://github.com/vidal-community","followers_url":"https://api.github.com/users/vidal-community/followers","following_url":"https://api.github.com/users/vidal-community/following{/other_user}","gists_url":"https://api.github.com/users/vidal-community/gists{/gist_id}","starred_url":"https://api.github.com/users/vidal-community/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vidal-community/subscriptions","organizations_url":"https://api.github.com/users/vidal-community/orgs","repos_url":"https://api.github.com/users/vidal-community/repos","events_url":"https://api.github.com/users/vidal-community/events{/privacy}","received_events_url":"https://api.github.com/users/vidal-community/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vidal-community/atom-jaxb","description":"Compliant Atom feeds with JAXB","fork":false,"url":"https://api.github.com/repos/vidal-community/atom-jaxb","forks_url":"https://api.github.com/repos/vidal-community/atom-jaxb/forks","keys_url":"https://api.github.com/repos/vidal-community/atom-jaxb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vidal-community/atom-jaxb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vidal-community/atom-jaxb/teams","hooks_url":"https://api.github.com/repos/vidal-community/atom-jaxb/hooks","issue_events_url":"https://api.github.com/repos/vidal-community/atom-jaxb/issues/events{/number}","events_url":"https://api.github.com/repos/vidal-community/atom-jaxb/events","assignees_url":"https://api.github.com/repos/vidal-community/atom-jaxb/assignees{/user}","branches_url":"https://api.github.com/repos/vidal-community/atom-jaxb/branches{/branch}","tags_url":"https://api.github.com/repos/vidal-community/atom-jaxb/tags","blobs_url":"https://api.github.com/repos/vidal-community/atom-jaxb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vidal-community/atom-jaxb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vidal-community/atom-jaxb/git/refs{/sha}","trees_url":"https://api.github.com/repos/vidal-community/atom-jaxb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vidal-community/atom-jaxb/statuses/{sha}","languages_url":"https://api.github.com/repos/vidal-community/atom-jaxb/languages","stargazers_url":"https://api.github.com/repos/vidal-community/atom-jaxb/stargazers","contributors_url":"https://api.github.com/repos/vidal-community/atom-jaxb/contributors","subscribers_url":"https://api.github.com/repos/vidal-community/atom-jaxb/subscribers","subscription_url":"https://api.github.com/repos/vidal-community/atom-jaxb/subscription","commits_url":"https://api.github.com/repos/vidal-community/atom-jaxb/commits{/sha}","git_commits_url":"https://api.github.com/repos/vidal-community/atom-jaxb/git/commits{/sha}","comments_url":"https://api.github.com/repos/vidal-community/atom-jaxb/comments{/number}","issue_comment_url":"https://api.github.com/repos/vidal-community/atom-jaxb/issues/comments{/number}","contents_url":"https://api.github.com/repos/vidal-community/atom-jaxb/contents/{+path}","compare_url":"https://api.github.com/repos/vidal-community/atom-jaxb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vidal-community/atom-jaxb/merges","archive_url":"https://api.github.com/repos/vidal-community/atom-jaxb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vidal-community/atom-jaxb/downloads","issues_url":"https://api.github.com/repos/vidal-community/atom-jaxb/issues{/number}","pulls_url":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls{/number}","milestones_url":"https://api.github.com/repos/vidal-community/atom-jaxb/milestones{/number}","notifications_url":"https://api.github.com/repos/vidal-community/atom-jaxb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vidal-community/atom-jaxb/labels{/name}","releases_url":"https://api.github.com/repos/vidal-community/atom-jaxb/releases{/id}","deployments_url":"https://api.github.com/repos/vidal-community/atom-jaxb/deployments","created_at":"2015-01-25T14:46:48Z","updated_at":"2018-04-12T10:39:46Z","pushed_at":"2018-05-24T09:49:12Z","git_url":"git://github.com/vidal-community/atom-jaxb.git","ssh_url":"git@github.com:vidal-community/atom-jaxb.git","clone_url":"https://github.com/vidal-community/atom-jaxb.git","svn_url":"https://github.com/vidal-community/atom-jaxb","homepage":"","size":185,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":11,"watchers":1,"default_branch":"master"}},"base":{"label":"vidal-community:master","ref":"master","sha":"40c386cf9d1d2534a09bbb9bb95a5f361de1ee3b","user":{"login":"vidal-community","id":12967061,"avatar_url":"https://avatars2.githubusercontent.com/u/12967061?v=4","gravatar_id":"","url":"https://api.github.com/users/vidal-community","html_url":"https://github.com/vidal-community","followers_url":"https://api.github.com/users/vidal-community/followers","following_url":"https://api.github.com/users/vidal-community/following{/other_user}","gists_url":"https://api.github.com/users/vidal-community/gists{/gist_id}","starred_url":"https://api.github.com/users/vidal-community/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vidal-community/subscriptions","organizations_url":"https://api.github.com/users/vidal-community/orgs","repos_url":"https://api.github.com/users/vidal-community/repos","events_url":"https://api.github.com/users/vidal-community/events{/privacy}","received_events_url":"https://api.github.com/users/vidal-community/received_events","type":"Organization","site_admin":false},"repo":{"id":29817265,"name":"atom-jaxb","full_name":"vidal-community/atom-jaxb","owner":{"login":"vidal-community","id":12967061,"avatar_url":"https://avatars2.githubusercontent.com/u/12967061?v=4","gravatar_id":"","url":"https://api.github.com/users/vidal-community","html_url":"https://github.com/vidal-community","followers_url":"https://api.github.com/users/vidal-community/followers","following_url":"https://api.github.com/users/vidal-community/following{/other_user}","gists_url":"https://api.github.com/users/vidal-community/gists{/gist_id}","starred_url":"https://api.github.com/users/vidal-community/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vidal-community/subscriptions","organizations_url":"https://api.github.com/users/vidal-community/orgs","repos_url":"https://api.github.com/users/vidal-community/repos","events_url":"https://api.github.com/users/vidal-community/events{/privacy}","received_events_url":"https://api.github.com/users/vidal-community/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vidal-community/atom-jaxb","description":"Compliant Atom feeds with JAXB","fork":false,"url":"https://api.github.com/repos/vidal-community/atom-jaxb","forks_url":"https://api.github.com/repos/vidal-community/atom-jaxb/forks","keys_url":"https://api.github.com/repos/vidal-community/atom-jaxb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vidal-community/atom-jaxb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vidal-community/atom-jaxb/teams","hooks_url":"https://api.github.com/repos/vidal-community/atom-jaxb/hooks","issue_events_url":"https://api.github.com/repos/vidal-community/atom-jaxb/issues/events{/number}","events_url":"https://api.github.com/repos/vidal-community/atom-jaxb/events","assignees_url":"https://api.github.com/repos/vidal-community/atom-jaxb/assignees{/user}","branches_url":"https://api.github.com/repos/vidal-community/atom-jaxb/branches{/branch}","tags_url":"https://api.github.com/repos/vidal-community/atom-jaxb/tags","blobs_url":"https://api.github.com/repos/vidal-community/atom-jaxb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vidal-community/atom-jaxb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vidal-community/atom-jaxb/git/refs{/sha}","trees_url":"https://api.github.com/repos/vidal-community/atom-jaxb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vidal-community/atom-jaxb/statuses/{sha}","languages_url":"https://api.github.com/repos/vidal-community/atom-jaxb/languages","stargazers_url":"https://api.github.com/repos/vidal-community/atom-jaxb/stargazers","contributors_url":"https://api.github.com/repos/vidal-community/atom-jaxb/contributors","subscribers_url":"https://api.github.com/repos/vidal-community/atom-jaxb/subscribers","subscription_url":"https://api.github.com/repos/vidal-community/atom-jaxb/subscription","commits_url":"https://api.github.com/repos/vidal-community/atom-jaxb/commits{/sha}","git_commits_url":"https://api.github.com/repos/vidal-community/atom-jaxb/git/commits{/sha}","comments_url":"https://api.github.com/repos/vidal-community/atom-jaxb/comments{/number}","issue_comment_url":"https://api.github.com/repos/vidal-community/atom-jaxb/issues/comments{/number}","contents_url":"https://api.github.com/repos/vidal-community/atom-jaxb/contents/{+path}","compare_url":"https://api.github.com/repos/vidal-community/atom-jaxb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vidal-community/atom-jaxb/merges","archive_url":"https://api.github.com/repos/vidal-community/atom-jaxb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vidal-community/atom-jaxb/downloads","issues_url":"https://api.github.com/repos/vidal-community/atom-jaxb/issues{/number}","pulls_url":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls{/number}","milestones_url":"https://api.github.com/repos/vidal-community/atom-jaxb/milestones{/number}","notifications_url":"https://api.github.com/repos/vidal-community/atom-jaxb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vidal-community/atom-jaxb/labels{/name}","releases_url":"https://api.github.com/repos/vidal-community/atom-jaxb/releases{/id}","deployments_url":"https://api.github.com/repos/vidal-community/atom-jaxb/deployments","created_at":"2015-01-25T14:46:48Z","updated_at":"2018-04-12T10:39:46Z","pushed_at":"2018-05-24T09:49:12Z","git_url":"git://github.com/vidal-community/atom-jaxb.git","ssh_url":"git@github.com:vidal-community/atom-jaxb.git","clone_url":"https://github.com/vidal-community/atom-jaxb.git","svn_url":"https://github.com/vidal-community/atom-jaxb","homepage":"","size":185,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":11,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/26"},"html":{"href":"https://github.com/vidal-community/atom-jaxb/pull/26"},"issue":{"href":"https://api.github.com/repos/vidal-community/atom-jaxb/issues/26"},"comments":{"href":"https://api.github.com/repos/vidal-community/atom-jaxb/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vidal-community/atom-jaxb/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/vidal-community/atom-jaxb/statuses/7f82f2840b8dccb0e76f9a89478fa6da0465756e"}},"author_association":"NONE"}}
{"actor":{"display_login":"fhiegel"}}