{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/comments/28552175","id":28552175,"diff_hunk":"@@ -122,14 +124,15 @@ public Entity call() throws Exception {\n                 default:\n                     throw new IllegalStateException(\"Unexpected scope \"+scope);\n             }\n-            \n-            Optional<Entity> result = Iterables.tryFind(entitiesToSearch, EntityPredicates.configEqualTo(BrooklynCampConstants.PLAN_ID, componentId));\n+            Predicate<Entity> configEqualTo = EntityPredicates.configEqualTo(BrooklynCampConstants.PLAN_ID, componentId);\n+            Predicate<Entity> classNameEquals = EntityPredicates.classNameEquals(componentId);\n+            Optional<Entity> result = Iterables.tryFind(entitiesToSearch, Predicates.or(configEqualTo, classNameEquals));","path":"usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java","position":17,"original_position":17,"commit_id":"34d796128c17e9c96bb6d1bd4804f7039a950829","original_commit_id":"34d796128c17e9c96bb6d1bd4804f7039a950829","user":{"login":"aledsage","id":593113,"avatar_url":"https://avatars.githubusercontent.com/u/593113?v=3","gravatar_id":"","url":"https://api.github.com/users/aledsage","html_url":"https://github.com/aledsage","followers_url":"https://api.github.com/users/aledsage/followers","following_url":"https://api.github.com/users/aledsage/following{/other_user}","gists_url":"https://api.github.com/users/aledsage/gists{/gist_id}","starred_url":"https://api.github.com/users/aledsage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aledsage/subscriptions","organizations_url":"https://api.github.com/users/aledsage/orgs","repos_url":"https://api.github.com/users/aledsage/repos","events_url":"https://api.github.com/users/aledsage/events{/privacy}","received_events_url":"https://api.github.com/users/aledsage/received_events","type":"User","site_admin":false},"body":"If the string matches both an id and a class name, then would be good to guarantee it will first match on id rather than it being dependent on the order that it walks through the entities. I'd therefore go for the more verbose:\r\n\r\n    Optional<Entity> result = Iterables.tryFind(entitiesToSearch, configEqualTo);\r\n    if (!result.isPresent()) result = Iterables.tryFind(entitiesToSearch, classNameEquals);\r\n","created_at":"2015-04-16T21:35:04Z","updated_at":"2015-04-16T21:35:04Z","html_url":"https://github.com/apache/incubator-brooklyn/pull/600#discussion_r28552175","pull_request_url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/600","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/comments/28552175"},"html":{"href":"https://github.com/apache/incubator-brooklyn/pull/600#discussion_r28552175"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/600"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/600","id":33342191,"html_url":"https://github.com/apache/incubator-brooklyn/pull/600","diff_url":"https://github.com/apache/incubator-brooklyn/pull/600.diff","patch_url":"https://github.com/apache/incubator-brooklyn/pull/600.patch","issue_url":"https://api.github.com/repos/apache/incubator-brooklyn/issues/600","number":600,"state":"open","locked":false,"title":"allow dsl commands to get an entity by type","user":{"login":"robertgmoss","id":1054185,"avatar_url":"https://avatars.githubusercontent.com/u/1054185?v=3","gravatar_id":"","url":"https://api.github.com/users/robertgmoss","html_url":"https://github.com/robertgmoss","followers_url":"https://api.github.com/users/robertgmoss/followers","following_url":"https://api.github.com/users/robertgmoss/following{/other_user}","gists_url":"https://api.github.com/users/robertgmoss/gists{/gist_id}","starred_url":"https://api.github.com/users/robertgmoss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertgmoss/subscriptions","organizations_url":"https://api.github.com/users/robertgmoss/orgs","repos_url":"https://api.github.com/users/robertgmoss/repos","events_url":"https://api.github.com/users/robertgmoss/events{/privacy}","received_events_url":"https://api.github.com/users/robertgmoss/received_events","type":"User","site_admin":false},"body":"e.g $brooklyn:descendant(\"brooklyn.entity.proxy.nginx.NginxController\")\r\nwill return the first descendent entity that has that type","created_at":"2015-04-15T10:39:40Z","updated_at":"2015-04-16T21:35:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"76405feef467e96528762a2e9d569470726c02d1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/600/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/600/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-brooklyn/issues/600/comments","statuses_url":"https://api.github.com/repos/apache/incubator-brooklyn/statuses/34d796128c17e9c96bb6d1bd4804f7039a950829","head":{"label":"robertgmoss:descendent-class","ref":"descendent-class","sha":"34d796128c17e9c96bb6d1bd4804f7039a950829","user":{"login":"robertgmoss","id":1054185,"avatar_url":"https://avatars.githubusercontent.com/u/1054185?v=3","gravatar_id":"","url":"https://api.github.com/users/robertgmoss","html_url":"https://github.com/robertgmoss","followers_url":"https://api.github.com/users/robertgmoss/followers","following_url":"https://api.github.com/users/robertgmoss/following{/other_user}","gists_url":"https://api.github.com/users/robertgmoss/gists{/gist_id}","starred_url":"https://api.github.com/users/robertgmoss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertgmoss/subscriptions","organizations_url":"https://api.github.com/users/robertgmoss/orgs","repos_url":"https://api.github.com/users/robertgmoss/repos","events_url":"https://api.github.com/users/robertgmoss/events{/privacy}","received_events_url":"https://api.github.com/users/robertgmoss/received_events","type":"User","site_admin":false},"repo":{"id":30183366,"name":"incubator-brooklyn","full_name":"robertgmoss/incubator-brooklyn","owner":{"login":"robertgmoss","id":1054185,"avatar_url":"https://avatars.githubusercontent.com/u/1054185?v=3","gravatar_id":"","url":"https://api.github.com/users/robertgmoss","html_url":"https://github.com/robertgmoss","followers_url":"https://api.github.com/users/robertgmoss/followers","following_url":"https://api.github.com/users/robertgmoss/following{/other_user}","gists_url":"https://api.github.com/users/robertgmoss/gists{/gist_id}","starred_url":"https://api.github.com/users/robertgmoss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertgmoss/subscriptions","organizations_url":"https://api.github.com/users/robertgmoss/orgs","repos_url":"https://api.github.com/users/robertgmoss/repos","events_url":"https://api.github.com/users/robertgmoss/events{/privacy}","received_events_url":"https://api.github.com/users/robertgmoss/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/robertgmoss/incubator-brooklyn","description":"Mirror of Apache Brooklyn","fork":true,"url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn","forks_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/forks","keys_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/teams","hooks_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/hooks","issue_events_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/issues/events{/number}","events_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/events","assignees_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/assignees{/user}","branches_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/branches{/branch}","tags_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/tags","blobs_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/statuses/{sha}","languages_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/languages","stargazers_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/stargazers","contributors_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/contributors","subscribers_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/subscribers","subscription_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/subscription","commits_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/contents/{+path}","compare_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/merges","archive_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/downloads","issues_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/issues{/number}","pulls_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/pulls{/number}","milestones_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/milestones{/number}","notifications_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/labels{/name}","releases_url":"https://api.github.com/repos/robertgmoss/incubator-brooklyn/releases{/id}","created_at":"2015-02-02T11:07:06Z","updated_at":"2015-04-14T10:25:49Z","pushed_at":"2015-04-16T16:55:49Z","git_url":"git://github.com/robertgmoss/incubator-brooklyn.git","ssh_url":"git@github.com:robertgmoss/incubator-brooklyn.git","clone_url":"https://github.com/robertgmoss/incubator-brooklyn.git","svn_url":"https://github.com/robertgmoss/incubator-brooklyn","homepage":null,"size":236144,"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":"master"}},"base":{"label":"apache:master","ref":"master","sha":"10853fc04f63ed42a2ee8e4a17ea1cd9830b755f","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":19368221,"name":"incubator-brooklyn","full_name":"apache/incubator-brooklyn","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-brooklyn","description":"Mirror of Apache Brooklyn","fork":false,"url":"https://api.github.com/repos/apache/incubator-brooklyn","forks_url":"https://api.github.com/repos/apache/incubator-brooklyn/forks","keys_url":"https://api.github.com/repos/apache/incubator-brooklyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-brooklyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-brooklyn/teams","hooks_url":"https://api.github.com/repos/apache/incubator-brooklyn/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-brooklyn/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-brooklyn/events","assignees_url":"https://api.github.com/repos/apache/incubator-brooklyn/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-brooklyn/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-brooklyn/tags","blobs_url":"https://api.github.com/repos/apache/incubator-brooklyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-brooklyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-brooklyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-brooklyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-brooklyn/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-brooklyn/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-brooklyn/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-brooklyn/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-brooklyn/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-brooklyn/subscription","commits_url":"https://api.github.com/repos/apache/incubator-brooklyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-brooklyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-brooklyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-brooklyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-brooklyn/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-brooklyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-brooklyn/merges","archive_url":"https://api.github.com/repos/apache/incubator-brooklyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-brooklyn/downloads","issues_url":"https://api.github.com/repos/apache/incubator-brooklyn/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-brooklyn/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-brooklyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-brooklyn/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-brooklyn/releases{/id}","created_at":"2014-05-02T07:00:07Z","updated_at":"2015-04-15T15:05:13Z","pushed_at":"2015-04-16T19:21:34Z","git_url":"git://github.com/apache/incubator-brooklyn.git","ssh_url":"git@github.com:apache/incubator-brooklyn.git","clone_url":"https://github.com/apache/incubator-brooklyn.git","svn_url":"https://github.com/apache/incubator-brooklyn","homepage":null,"size":247342,"stargazers_count":66,"watchers_count":66,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":54,"mirror_url":"git://git.apache.org/incubator-brooklyn.git","open_issues_count":10,"forks":54,"open_issues":10,"watchers":66,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/600"},"html":{"href":"https://github.com/apache/incubator-brooklyn/pull/600"},"issue":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/issues/600"},"comments":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/issues/600/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/600/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/600/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/statuses/34d796128c17e9c96bb6d1bd4804f7039a950829"}}}}