{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/comments/77023141","id":77023141,"diff_hunk":"@@ -905,13 +905,41 @@ public T detect(Predicate<? super T> predicate)\n     }\n \n     @Override\n+    public <P> T detectWith(Predicate2<? super T, ? super P> predicate, P parameter)\n+    {\n+        return InternalArrayIterate.detectWith(this.items, this.size, predicate, parameter);\n+    }\n+\n+    @Override\n+    public Optional<T> detectOptional(Predicate<? super T> predicate)\n+    {\n+        return InternalArrayIterate.detectOptional(this.items, this.size, predicate);\n+    }\n+\n+    @Override\n+    public <P> Optional<T> detectWithOptional(Predicate2<? super T, ? super P> predicate, P parameter)\n+    {\n+        return InternalArrayIterate.detectWithOptional(this.items, this.size, predicate, parameter);\n+    }\n+\n+    @Override\n     public T detectIfNone(Predicate<? super T> predicate, Function0<? extends T> defaultValueBlock)\n     {\n         T result = this.detect(predicate);\n         return result == null ? defaultValueBlock.value() : result;\n     }\n \n     @Override\n+    public <P> T detectWithIfNone(\n+            Predicate2<? super T, ? super P> predicate,\n+            P parameter,\n+            Function0<? extends T> defaultValueBlock)\n+    {\n+        T result = this.detectWith(predicate, parameter);\n+        return result == null ? defaultValueBlock.value() : result;\n+    }\n+","path":"eclipse-collections/src/main/java/org/eclipse/collections/impl/list/mutable/FastList.java","position":null,"original_position":37,"commit_id":"ef6991ab2c090201adf5dee1b058662ffad484da","original_commit_id":"16e1cc60f767f4b860f287066f53699d53403ae8","user":{"login":"itohro","id":15612969,"avatar_url":"https://avatars.githubusercontent.com/u/15612969?v=3","gravatar_id":"","url":"https://api.github.com/users/itohro","html_url":"https://github.com/itohro","followers_url":"https://api.github.com/users/itohro/followers","following_url":"https://api.github.com/users/itohro/following{/other_user}","gists_url":"https://api.github.com/users/itohro/gists{/gist_id}","starred_url":"https://api.github.com/users/itohro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itohro/subscriptions","organizations_url":"https://api.github.com/users/itohro/orgs","repos_url":"https://api.github.com/users/itohro/repos","events_url":"https://api.github.com/users/itohro/events{/privacy}","received_events_url":"https://api.github.com/users/itohro/received_events","type":"User","site_admin":false},"body":"There is one interesting edge case where this doesn't work.\r\n\r\n```java\r\nAssert.assertEquals(Integer.valueOf(3), this.newWith(Comparators.reverseNaturalOrder(), 2, 3, 4, 5).detectIfNone(Integer.valueOf(3)::equals, null));\r\n```\r\n\r\nWhen it detects an element that meets the predicate condition, it should return it even if the function passed is null. However it throws NullPointerException with the method reference approach above (it seems method reference is \"evaluated\" even though it is not executed in the code path). \r\n\r\nWe can change it as below to address this particular case still using detectOptional().\r\n\r\n```java\r\nthis.detectOptional(predicate).orElseGet(() -> (function == null) ? null : function.value());\r\n```\r\n\r\nHowever now this code behaves differently from the original code when it detects null AND null function is passed in. Original code throws NPE, while the code above returns null.\r\n\r\nI think this behaviour was not documented or tested anywhere, but I suppose original code behaves more naturally in this case (throws NPE). \r\n\r\nSo I'd revert this to be original null check code. Let me know what you think.","created_at":"2016-08-31T16:35:14Z","updated_at":"2016-08-31T16:35:14Z","html_url":"https://github.com/eclipse/eclipse-collections/pull/136#discussion_r77023141","pull_request_url":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/136","_links":{"self":{"href":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/comments/77023141"},"html":{"href":"https://github.com/eclipse/eclipse-collections/pull/136#discussion_r77023141"},"pull_request":{"href":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/136"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/136","id":82001054,"html_url":"https://github.com/eclipse/eclipse-collections/pull/136","diff_url":"https://github.com/eclipse/eclipse-collections/pull/136.diff","patch_url":"https://github.com/eclipse/eclipse-collections/pull/136.patch","issue_url":"https://api.github.com/repos/eclipse/eclipse-collections/issues/136","number":136,"state":"open","locked":false,"title":"Make detectOptional methods throw NullPointerException when detecting null value.","user":{"login":"itohro","id":15612969,"avatar_url":"https://avatars.githubusercontent.com/u/15612969?v=3","gravatar_id":"","url":"https://api.github.com/users/itohro","html_url":"https://github.com/itohro","followers_url":"https://api.github.com/users/itohro/followers","following_url":"https://api.github.com/users/itohro/following{/other_user}","gists_url":"https://api.github.com/users/itohro/gists{/gist_id}","starred_url":"https://api.github.com/users/itohro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itohro/subscriptions","organizations_url":"https://api.github.com/users/itohro/orgs","repos_url":"https://api.github.com/users/itohro/repos","events_url":"https://api.github.com/users/itohro/events{/privacy}","received_events_url":"https://api.github.com/users/itohro/received_events","type":"User","site_admin":false},"body":"Revisiting the comment below from #115.\r\n\r\n>There's one weird case where it's not ok to delegate to ofNullable(). The map, or iterable, could contain a null value and the predicate could be each -> each == null. There's no great way to handle that case, but it's not great to return empty() when something was actually found. The alternative would be calling Optional.of(null) which throws, but is arguably more correct.\r\n\r\nFollowing what's suggested in the last line above and also what `Streams#findFirst()` does, I made detectOptional methods throw NullPointerException when null value is detected. ","created_at":"2016-08-19T15:36:52Z","updated_at":"2016-08-31T16:35:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d6a9e5121cce4d2ced546402a486630f6b2c2cbf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/136/commits","review_comments_url":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/136/comments","review_comment_url":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/eclipse-collections/issues/136/comments","statuses_url":"https://api.github.com/repos/eclipse/eclipse-collections/statuses/ef6991ab2c090201adf5dee1b058662ffad484da","head":{"label":"itohro:master","ref":"master","sha":"ef6991ab2c090201adf5dee1b058662ffad484da","user":{"login":"itohro","id":15612969,"avatar_url":"https://avatars.githubusercontent.com/u/15612969?v=3","gravatar_id":"","url":"https://api.github.com/users/itohro","html_url":"https://github.com/itohro","followers_url":"https://api.github.com/users/itohro/followers","following_url":"https://api.github.com/users/itohro/following{/other_user}","gists_url":"https://api.github.com/users/itohro/gists{/gist_id}","starred_url":"https://api.github.com/users/itohro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itohro/subscriptions","organizations_url":"https://api.github.com/users/itohro/orgs","repos_url":"https://api.github.com/users/itohro/repos","events_url":"https://api.github.com/users/itohro/events{/privacy}","received_events_url":"https://api.github.com/users/itohro/received_events","type":"User","site_admin":false},"repo":{"id":47745232,"name":"eclipse-collections","full_name":"itohro/eclipse-collections","owner":{"login":"itohro","id":15612969,"avatar_url":"https://avatars.githubusercontent.com/u/15612969?v=3","gravatar_id":"","url":"https://api.github.com/users/itohro","html_url":"https://github.com/itohro","followers_url":"https://api.github.com/users/itohro/followers","following_url":"https://api.github.com/users/itohro/following{/other_user}","gists_url":"https://api.github.com/users/itohro/gists{/gist_id}","starred_url":"https://api.github.com/users/itohro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itohro/subscriptions","organizations_url":"https://api.github.com/users/itohro/orgs","repos_url":"https://api.github.com/users/itohro/repos","events_url":"https://api.github.com/users/itohro/events{/privacy}","received_events_url":"https://api.github.com/users/itohro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/itohro/eclipse-collections","description":"The Eclipse Collections Project","fork":true,"url":"https://api.github.com/repos/itohro/eclipse-collections","forks_url":"https://api.github.com/repos/itohro/eclipse-collections/forks","keys_url":"https://api.github.com/repos/itohro/eclipse-collections/keys{/key_id}","collaborators_url":"https://api.github.com/repos/itohro/eclipse-collections/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/itohro/eclipse-collections/teams","hooks_url":"https://api.github.com/repos/itohro/eclipse-collections/hooks","issue_events_url":"https://api.github.com/repos/itohro/eclipse-collections/issues/events{/number}","events_url":"https://api.github.com/repos/itohro/eclipse-collections/events","assignees_url":"https://api.github.com/repos/itohro/eclipse-collections/assignees{/user}","branches_url":"https://api.github.com/repos/itohro/eclipse-collections/branches{/branch}","tags_url":"https://api.github.com/repos/itohro/eclipse-collections/tags","blobs_url":"https://api.github.com/repos/itohro/eclipse-collections/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/itohro/eclipse-collections/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/itohro/eclipse-collections/git/refs{/sha}","trees_url":"https://api.github.com/repos/itohro/eclipse-collections/git/trees{/sha}","statuses_url":"https://api.github.com/repos/itohro/eclipse-collections/statuses/{sha}","languages_url":"https://api.github.com/repos/itohro/eclipse-collections/languages","stargazers_url":"https://api.github.com/repos/itohro/eclipse-collections/stargazers","contributors_url":"https://api.github.com/repos/itohro/eclipse-collections/contributors","subscribers_url":"https://api.github.com/repos/itohro/eclipse-collections/subscribers","subscription_url":"https://api.github.com/repos/itohro/eclipse-collections/subscription","commits_url":"https://api.github.com/repos/itohro/eclipse-collections/commits{/sha}","git_commits_url":"https://api.github.com/repos/itohro/eclipse-collections/git/commits{/sha}","comments_url":"https://api.github.com/repos/itohro/eclipse-collections/comments{/number}","issue_comment_url":"https://api.github.com/repos/itohro/eclipse-collections/issues/comments{/number}","contents_url":"https://api.github.com/repos/itohro/eclipse-collections/contents/{+path}","compare_url":"https://api.github.com/repos/itohro/eclipse-collections/compare/{base}...{head}","merges_url":"https://api.github.com/repos/itohro/eclipse-collections/merges","archive_url":"https://api.github.com/repos/itohro/eclipse-collections/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/itohro/eclipse-collections/downloads","issues_url":"https://api.github.com/repos/itohro/eclipse-collections/issues{/number}","pulls_url":"https://api.github.com/repos/itohro/eclipse-collections/pulls{/number}","milestones_url":"https://api.github.com/repos/itohro/eclipse-collections/milestones{/number}","notifications_url":"https://api.github.com/repos/itohro/eclipse-collections/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/itohro/eclipse-collections/labels{/name}","releases_url":"https://api.github.com/repos/itohro/eclipse-collections/releases{/id}","deployments_url":"https://api.github.com/repos/itohro/eclipse-collections/deployments","created_at":"2015-12-10T07:27:15Z","updated_at":"2016-01-13T13:46:25Z","pushed_at":"2016-08-31T16:32:44Z","git_url":"git://github.com/itohro/eclipse-collections.git","ssh_url":"git@github.com:itohro/eclipse-collections.git","clone_url":"https://github.com/itohro/eclipse-collections.git","svn_url":"https://github.com/itohro/eclipse-collections","homepage":"http://www.eclipse.org/collections","size":5632,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"6dc38c8d70b76b86d5955f191e231dccefac50ee","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":46803767,"name":"eclipse-collections","full_name":"eclipse/eclipse-collections","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/eclipse-collections","description":"The Eclipse Collections Project","fork":false,"url":"https://api.github.com/repos/eclipse/eclipse-collections","forks_url":"https://api.github.com/repos/eclipse/eclipse-collections/forks","keys_url":"https://api.github.com/repos/eclipse/eclipse-collections/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/eclipse-collections/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/eclipse-collections/teams","hooks_url":"https://api.github.com/repos/eclipse/eclipse-collections/hooks","issue_events_url":"https://api.github.com/repos/eclipse/eclipse-collections/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/eclipse-collections/events","assignees_url":"https://api.github.com/repos/eclipse/eclipse-collections/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/eclipse-collections/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/eclipse-collections/tags","blobs_url":"https://api.github.com/repos/eclipse/eclipse-collections/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/eclipse-collections/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/eclipse-collections/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/eclipse-collections/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/eclipse-collections/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/eclipse-collections/languages","stargazers_url":"https://api.github.com/repos/eclipse/eclipse-collections/stargazers","contributors_url":"https://api.github.com/repos/eclipse/eclipse-collections/contributors","subscribers_url":"https://api.github.com/repos/eclipse/eclipse-collections/subscribers","subscription_url":"https://api.github.com/repos/eclipse/eclipse-collections/subscription","commits_url":"https://api.github.com/repos/eclipse/eclipse-collections/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/eclipse-collections/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/eclipse-collections/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/eclipse-collections/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/eclipse-collections/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/eclipse-collections/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/eclipse-collections/merges","archive_url":"https://api.github.com/repos/eclipse/eclipse-collections/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/eclipse-collections/downloads","issues_url":"https://api.github.com/repos/eclipse/eclipse-collections/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/eclipse-collections/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/eclipse-collections/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/eclipse-collections/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/eclipse-collections/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/eclipse-collections/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/eclipse-collections/deployments","created_at":"2015-11-24T16:22:48Z","updated_at":"2016-08-28T00:47:01Z","pushed_at":"2016-08-31T16:32:44Z","git_url":"git://github.com/eclipse/eclipse-collections.git","ssh_url":"git@github.com:eclipse/eclipse-collections.git","clone_url":"https://github.com/eclipse/eclipse-collections.git","svn_url":"https://github.com/eclipse/eclipse-collections","homepage":"http://www.eclipse.org/collections","size":5763,"stargazers_count":171,"watchers_count":171,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":42,"mirror_url":null,"open_issues_count":14,"forks":42,"open_issues":14,"watchers":171,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/136"},"html":{"href":"https://github.com/eclipse/eclipse-collections/pull/136"},"issue":{"href":"https://api.github.com/repos/eclipse/eclipse-collections/issues/136"},"comments":{"href":"https://api.github.com/repos/eclipse/eclipse-collections/issues/136/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/136/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/eclipse-collections/pulls/136/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/eclipse-collections/statuses/ef6991ab2c090201adf5dee1b058662ffad484da"}}}}
{"actor":{"display_login":"itohro"}}