{"action":"created","comment":{"url":"https://api.github.com/repos/jdbi/jdbi/pulls/comments/51356345","id":51356345,"diff_hunk":"@@ -0,0 +1,60 @@\n+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package org.jdbi.v3;\n+\n+import static org.jdbi.v3.internal.JdbiStreams.toStream;\n+\n+import java.lang.reflect.Type;\n+import java.util.List;\n+import java.util.Optional;\n+import java.util.concurrent.CopyOnWriteArrayList;\n+import java.util.stream.Stream;\n+\n+import org.jdbi.v3.tweak.Argument;\n+import org.jdbi.v3.tweak.ArgumentFactory;\n+\n+class ArgumentRegistry\n+{\n+\n+    static ArgumentRegistry copyOf(ArgumentRegistry registry) {\n+        return new ArgumentRegistry(registry.factories);\n+    }\n+\n+    private final List<ArgumentFactory> factories = new CopyOnWriteArrayList<>();\n+\n+    ArgumentRegistry()\n+    {\n+        factories.add(BuiltInArgumentFactory.INSTANCE);\n+    }\n+\n+    ArgumentRegistry(List<ArgumentFactory> factories)\n+    {\n+        this.factories.addAll(factories);\n+    }\n+\n+    Optional<Argument> findArgumentFor(Type expectedType, Object it, StatementContext ctx)\n+    {\n+        return Stream.concat(\n+                // Search first for factories accepting specific argument type\n+                factories.stream().flatMap(factory -> toStream(factory.build(expectedType, it, ctx))),\n+                // Fall back to any factory accepting Object if necessary\n+                factories.stream().flatMap(factory -> toStream(factory.build(Object.class, it, ctx))))\n+                .findFirst();\n+    }\n+\n+    void register(ArgumentFactory argumentFactory)\n+    {\n+        factories.add(0, argumentFactory);","path":"core/src/main/java/org/jdbi/v3/ArgumentRegistry.java","position":58,"original_position":58,"commit_id":"c94ccbedaea718ebb241c6777e24f45ca48f3899","original_commit_id":"89ca5224c434452b69b38776596e74ad8c04550d","user":{"login":"qualidafial","id":38629,"avatar_url":"https://avatars.githubusercontent.com/u/38629?v=3","gravatar_id":"","url":"https://api.github.com/users/qualidafial","html_url":"https://github.com/qualidafial","followers_url":"https://api.github.com/users/qualidafial/followers","following_url":"https://api.github.com/users/qualidafial/following{/other_user}","gists_url":"https://api.github.com/users/qualidafial/gists{/gist_id}","starred_url":"https://api.github.com/users/qualidafial/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qualidafial/subscriptions","organizations_url":"https://api.github.com/users/qualidafial/orgs","repos_url":"https://api.github.com/users/qualidafial/repos","events_url":"https://api.github.com/users/qualidafial/events{/privacy}","received_events_url":"https://api.github.com/users/qualidafial/received_events","type":"User","site_admin":false},"body":"That worked. The last change makes it so you have to specify which classes you want to register bean mappers for:\r\n\r\n    dbi.registerMapper(new BeanMapperFactory(Foo.class, Bar.class, ...))\r\n\r\nOr for SQL objects:\r\n\r\n    @RegisterBeanMapper({Foo.class, Bar.class, ...})","created_at":"2016-01-31T07:09:05Z","updated_at":"2016-01-31T07:09:05Z","html_url":"https://github.com/jdbi/jdbi/pull/259#discussion_r51356345","pull_request_url":"https://api.github.com/repos/jdbi/jdbi/pulls/259","_links":{"self":{"href":"https://api.github.com/repos/jdbi/jdbi/pulls/comments/51356345"},"html":{"href":"https://github.com/jdbi/jdbi/pull/259#discussion_r51356345"},"pull_request":{"href":"https://api.github.com/repos/jdbi/jdbi/pulls/259"}}},"pull_request":{"url":"https://api.github.com/repos/jdbi/jdbi/pulls/259","id":57012830,"html_url":"https://github.com/jdbi/jdbi/pull/259","diff_url":"https://github.com/jdbi/jdbi/pull/259.diff","patch_url":"https://github.com/jdbi/jdbi/pull/259.patch","issue_url":"https://api.github.com/repos/jdbi/jdbi/issues/259","number":259,"state":"open","locked":false,"title":"Registries and factories should use optional types","user":{"login":"qualidafial","id":38629,"avatar_url":"https://avatars.githubusercontent.com/u/38629?v=3","gravatar_id":"","url":"https://api.github.com/users/qualidafial","html_url":"https://github.com/qualidafial","followers_url":"https://api.github.com/users/qualidafial/followers","following_url":"https://api.github.com/users/qualidafial/following{/other_user}","gists_url":"https://api.github.com/users/qualidafial/gists{/gist_id}","starred_url":"https://api.github.com/users/qualidafial/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qualidafial/subscriptions","organizations_url":"https://api.github.com/users/qualidafial/orgs","repos_url":"https://api.github.com/users/qualidafial/repos","events_url":"https://api.github.com/users/qualidafial/events{/privacy}","received_events_url":"https://api.github.com/users/qualidafial/received_events","type":"User","site_admin":false},"body":"Work in progress to address #208 \r\n\r\n* [x] Coalesce ArgumentFactory methods and return optional\r\n* [x] Coalesce ResultSetMapperFactory methods and return optional\r\n* [x] Coalesce ResultColumnMapperFactory methods and return optional\r\n* [x] Coalesce CollectorFactory methods and return optional\r\n* [x] Foreman.waffle returns optional\r\n* [x] MappingRegistry.columnMapperFor returns optional\r\n* [x] MappingRegistry.mapperFor returns optional\r\n* [x] CollectorFactoryRegistry.createCollectorFor returns optional\r\n* [x] StatementContext.argumentFor return optional\r\n* [x] StatementContext.columnMapperFor return optional\r\n* [x] StatementContext.collectorFor return optional\r\n* [x] Rename Foreman to ArgumentRegistry\r\n* [x] Methods that return optional should be named with `find` prefix for consistency.\r\n* [x] NamedArgumentFinder.find return optional\r\n* [x] Binding.forName/forPosition return optional, rename with `find` prefix\r\n* [x] Add `@FunctionalInterface` annotation as appropriate\r\n* [ ] Make order of factory precedence consistent between all registries.","created_at":"2016-01-24T20:28:58Z","updated_at":"2016-01-31T07:09:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"21b23e3f531d9125a3c10b0f3cdb07615560b1c8","assignee":{"login":"stevenschlansker","id":129097,"avatar_url":"https://avatars.githubusercontent.com/u/129097?v=3","gravatar_id":"","url":"https://api.github.com/users/stevenschlansker","html_url":"https://github.com/stevenschlansker","followers_url":"https://api.github.com/users/stevenschlansker/followers","following_url":"https://api.github.com/users/stevenschlansker/following{/other_user}","gists_url":"https://api.github.com/users/stevenschlansker/gists{/gist_id}","starred_url":"https://api.github.com/users/stevenschlansker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevenschlansker/subscriptions","organizations_url":"https://api.github.com/users/stevenschlansker/orgs","repos_url":"https://api.github.com/users/stevenschlansker/repos","events_url":"https://api.github.com/users/stevenschlansker/events{/privacy}","received_events_url":"https://api.github.com/users/stevenschlansker/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/jdbi/jdbi/milestones/2","html_url":"https://github.com/jdbi/jdbi/milestones/JDBI%203","labels_url":"https://api.github.com/repos/jdbi/jdbi/milestones/2/labels","id":382959,"number":2,"title":"JDBI 3","description":"Bucket for issues that should be in JDBI 3","creator":{"login":"stevenschlansker","id":129097,"avatar_url":"https://avatars.githubusercontent.com/u/129097?v=3","gravatar_id":"","url":"https://api.github.com/users/stevenschlansker","html_url":"https://github.com/stevenschlansker","followers_url":"https://api.github.com/users/stevenschlansker/followers","following_url":"https://api.github.com/users/stevenschlansker/following{/other_user}","gists_url":"https://api.github.com/users/stevenschlansker/gists{/gist_id}","starred_url":"https://api.github.com/users/stevenschlansker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevenschlansker/subscriptions","organizations_url":"https://api.github.com/users/stevenschlansker/orgs","repos_url":"https://api.github.com/users/stevenschlansker/repos","events_url":"https://api.github.com/users/stevenschlansker/events{/privacy}","received_events_url":"https://api.github.com/users/stevenschlansker/received_events","type":"User","site_admin":false},"open_issues":19,"closed_issues":35,"state":"open","created_at":"2013-07-20T23:48:16Z","updated_at":"2016-01-30T00:06:56Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/jdbi/jdbi/pulls/259/commits","review_comments_url":"https://api.github.com/repos/jdbi/jdbi/pulls/259/comments","review_comment_url":"https://api.github.com/repos/jdbi/jdbi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jdbi/jdbi/issues/259/comments","statuses_url":"https://api.github.com/repos/jdbi/jdbi/statuses/c94ccbedaea718ebb241c6777e24f45ca48f3899","head":{"label":"qualidafial:coalesce-factory-methods","ref":"coalesce-factory-methods","sha":"c94ccbedaea718ebb241c6777e24f45ca48f3899","user":{"login":"qualidafial","id":38629,"avatar_url":"https://avatars.githubusercontent.com/u/38629?v=3","gravatar_id":"","url":"https://api.github.com/users/qualidafial","html_url":"https://github.com/qualidafial","followers_url":"https://api.github.com/users/qualidafial/followers","following_url":"https://api.github.com/users/qualidafial/following{/other_user}","gists_url":"https://api.github.com/users/qualidafial/gists{/gist_id}","starred_url":"https://api.github.com/users/qualidafial/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qualidafial/subscriptions","organizations_url":"https://api.github.com/users/qualidafial/orgs","repos_url":"https://api.github.com/users/qualidafial/repos","events_url":"https://api.github.com/users/qualidafial/events{/privacy}","received_events_url":"https://api.github.com/users/qualidafial/received_events","type":"User","site_admin":false},"repo":{"id":43560141,"name":"jdbi","full_name":"qualidafial/jdbi","owner":{"login":"qualidafial","id":38629,"avatar_url":"https://avatars.githubusercontent.com/u/38629?v=3","gravatar_id":"","url":"https://api.github.com/users/qualidafial","html_url":"https://github.com/qualidafial","followers_url":"https://api.github.com/users/qualidafial/followers","following_url":"https://api.github.com/users/qualidafial/following{/other_user}","gists_url":"https://api.github.com/users/qualidafial/gists{/gist_id}","starred_url":"https://api.github.com/users/qualidafial/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qualidafial/subscriptions","organizations_url":"https://api.github.com/users/qualidafial/orgs","repos_url":"https://api.github.com/users/qualidafial/repos","events_url":"https://api.github.com/users/qualidafial/events{/privacy}","received_events_url":"https://api.github.com/users/qualidafial/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/qualidafial/jdbi","description":"jDBI is designed to provide convenient tabular data access in Java(tm). It uses the Java collections framework for query results, provides a convenient means of externalizing sql statements, and provides named parameter support for any database being used.","fork":true,"url":"https://api.github.com/repos/qualidafial/jdbi","forks_url":"https://api.github.com/repos/qualidafial/jdbi/forks","keys_url":"https://api.github.com/repos/qualidafial/jdbi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/qualidafial/jdbi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/qualidafial/jdbi/teams","hooks_url":"https://api.github.com/repos/qualidafial/jdbi/hooks","issue_events_url":"https://api.github.com/repos/qualidafial/jdbi/issues/events{/number}","events_url":"https://api.github.com/repos/qualidafial/jdbi/events","assignees_url":"https://api.github.com/repos/qualidafial/jdbi/assignees{/user}","branches_url":"https://api.github.com/repos/qualidafial/jdbi/branches{/branch}","tags_url":"https://api.github.com/repos/qualidafial/jdbi/tags","blobs_url":"https://api.github.com/repos/qualidafial/jdbi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/qualidafial/jdbi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/qualidafial/jdbi/git/refs{/sha}","trees_url":"https://api.github.com/repos/qualidafial/jdbi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/qualidafial/jdbi/statuses/{sha}","languages_url":"https://api.github.com/repos/qualidafial/jdbi/languages","stargazers_url":"https://api.github.com/repos/qualidafial/jdbi/stargazers","contributors_url":"https://api.github.com/repos/qualidafial/jdbi/contributors","subscribers_url":"https://api.github.com/repos/qualidafial/jdbi/subscribers","subscription_url":"https://api.github.com/repos/qualidafial/jdbi/subscription","commits_url":"https://api.github.com/repos/qualidafial/jdbi/commits{/sha}","git_commits_url":"https://api.github.com/repos/qualidafial/jdbi/git/commits{/sha}","comments_url":"https://api.github.com/repos/qualidafial/jdbi/comments{/number}","issue_comment_url":"https://api.github.com/repos/qualidafial/jdbi/issues/comments{/number}","contents_url":"https://api.github.com/repos/qualidafial/jdbi/contents/{+path}","compare_url":"https://api.github.com/repos/qualidafial/jdbi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/qualidafial/jdbi/merges","archive_url":"https://api.github.com/repos/qualidafial/jdbi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/qualidafial/jdbi/downloads","issues_url":"https://api.github.com/repos/qualidafial/jdbi/issues{/number}","pulls_url":"https://api.github.com/repos/qualidafial/jdbi/pulls{/number}","milestones_url":"https://api.github.com/repos/qualidafial/jdbi/milestones{/number}","notifications_url":"https://api.github.com/repos/qualidafial/jdbi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/qualidafial/jdbi/labels{/name}","releases_url":"https://api.github.com/repos/qualidafial/jdbi/releases{/id}","deployments_url":"https://api.github.com/repos/qualidafial/jdbi/deployments","created_at":"2015-10-02T15:20:45Z","updated_at":"2016-01-15T22:58:44Z","pushed_at":"2016-01-31T07:01:51Z","git_url":"git://github.com/qualidafial/jdbi.git","ssh_url":"git@github.com:qualidafial/jdbi.git","clone_url":"https://github.com/qualidafial/jdbi.git","svn_url":"https://github.com/qualidafial/jdbi","homepage":"http://jdbi.org/","size":13061,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"jdbi3"}},"base":{"label":"jdbi:jdbi3","ref":"jdbi3","sha":"d4394692c66c753f67db0ea83c396858837a11dc","user":{"login":"jdbi","id":9668860,"avatar_url":"https://avatars.githubusercontent.com/u/9668860?v=3","gravatar_id":"","url":"https://api.github.com/users/jdbi","html_url":"https://github.com/jdbi","followers_url":"https://api.github.com/users/jdbi/followers","following_url":"https://api.github.com/users/jdbi/following{/other_user}","gists_url":"https://api.github.com/users/jdbi/gists{/gist_id}","starred_url":"https://api.github.com/users/jdbi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdbi/subscriptions","organizations_url":"https://api.github.com/users/jdbi/orgs","repos_url":"https://api.github.com/users/jdbi/repos","events_url":"https://api.github.com/users/jdbi/events{/privacy}","received_events_url":"https://api.github.com/users/jdbi/received_events","type":"Organization","site_admin":false},"repo":{"id":229738,"name":"jdbi","full_name":"jdbi/jdbi","owner":{"login":"jdbi","id":9668860,"avatar_url":"https://avatars.githubusercontent.com/u/9668860?v=3","gravatar_id":"","url":"https://api.github.com/users/jdbi","html_url":"https://github.com/jdbi","followers_url":"https://api.github.com/users/jdbi/followers","following_url":"https://api.github.com/users/jdbi/following{/other_user}","gists_url":"https://api.github.com/users/jdbi/gists{/gist_id}","starred_url":"https://api.github.com/users/jdbi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdbi/subscriptions","organizations_url":"https://api.github.com/users/jdbi/orgs","repos_url":"https://api.github.com/users/jdbi/repos","events_url":"https://api.github.com/users/jdbi/events{/privacy}","received_events_url":"https://api.github.com/users/jdbi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jdbi/jdbi","description":"jDBI is designed to provide convenient tabular data access in Java(tm). It uses the Java collections framework for query results, provides a convenient means of externalizing sql statements, and provides named parameter support for any database being used.","fork":false,"url":"https://api.github.com/repos/jdbi/jdbi","forks_url":"https://api.github.com/repos/jdbi/jdbi/forks","keys_url":"https://api.github.com/repos/jdbi/jdbi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jdbi/jdbi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jdbi/jdbi/teams","hooks_url":"https://api.github.com/repos/jdbi/jdbi/hooks","issue_events_url":"https://api.github.com/repos/jdbi/jdbi/issues/events{/number}","events_url":"https://api.github.com/repos/jdbi/jdbi/events","assignees_url":"https://api.github.com/repos/jdbi/jdbi/assignees{/user}","branches_url":"https://api.github.com/repos/jdbi/jdbi/branches{/branch}","tags_url":"https://api.github.com/repos/jdbi/jdbi/tags","blobs_url":"https://api.github.com/repos/jdbi/jdbi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jdbi/jdbi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jdbi/jdbi/git/refs{/sha}","trees_url":"https://api.github.com/repos/jdbi/jdbi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jdbi/jdbi/statuses/{sha}","languages_url":"https://api.github.com/repos/jdbi/jdbi/languages","stargazers_url":"https://api.github.com/repos/jdbi/jdbi/stargazers","contributors_url":"https://api.github.com/repos/jdbi/jdbi/contributors","subscribers_url":"https://api.github.com/repos/jdbi/jdbi/subscribers","subscription_url":"https://api.github.com/repos/jdbi/jdbi/subscription","commits_url":"https://api.github.com/repos/jdbi/jdbi/commits{/sha}","git_commits_url":"https://api.github.com/repos/jdbi/jdbi/git/commits{/sha}","comments_url":"https://api.github.com/repos/jdbi/jdbi/comments{/number}","issue_comment_url":"https://api.github.com/repos/jdbi/jdbi/issues/comments{/number}","contents_url":"https://api.github.com/repos/jdbi/jdbi/contents/{+path}","compare_url":"https://api.github.com/repos/jdbi/jdbi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jdbi/jdbi/merges","archive_url":"https://api.github.com/repos/jdbi/jdbi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jdbi/jdbi/downloads","issues_url":"https://api.github.com/repos/jdbi/jdbi/issues{/number}","pulls_url":"https://api.github.com/repos/jdbi/jdbi/pulls{/number}","milestones_url":"https://api.github.com/repos/jdbi/jdbi/milestones{/number}","notifications_url":"https://api.github.com/repos/jdbi/jdbi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jdbi/jdbi/labels{/name}","releases_url":"https://api.github.com/repos/jdbi/jdbi/releases{/id}","deployments_url":"https://api.github.com/repos/jdbi/jdbi/deployments","created_at":"2009-06-17T16:36:36Z","updated_at":"2016-01-28T18:30:48Z","pushed_at":"2016-01-31T07:01:51Z","git_url":"git://github.com/jdbi/jdbi.git","ssh_url":"git@github.com:jdbi/jdbi.git","clone_url":"https://github.com/jdbi/jdbi.git","svn_url":"https://github.com/jdbi/jdbi","homepage":"http://jdbi.org/","size":13380,"stargazers_count":575,"watchers_count":575,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":134,"mirror_url":null,"open_issues_count":38,"forks":134,"open_issues":38,"watchers":575,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jdbi/jdbi/pulls/259"},"html":{"href":"https://github.com/jdbi/jdbi/pull/259"},"issue":{"href":"https://api.github.com/repos/jdbi/jdbi/issues/259"},"comments":{"href":"https://api.github.com/repos/jdbi/jdbi/issues/259/comments"},"review_comments":{"href":"https://api.github.com/repos/jdbi/jdbi/pulls/259/comments"},"review_comment":{"href":"https://api.github.com/repos/jdbi/jdbi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jdbi/jdbi/pulls/259/commits"},"statuses":{"href":"https://api.github.com/repos/jdbi/jdbi/statuses/c94ccbedaea718ebb241c6777e24f45ca48f3899"}}}}