{"action":"created","comment":{"url":"https://api.github.com/repos/KyoriPowered/text/pulls/comments/133357780","pull_request_review_id":56528162,"id":133357780,"diff_hunk":"@@ -74,6 +77,45 @@\n     B append(@Nonnull final Iterable<? extends Component> components);\n \n     /**\n+     * Applies an action to this builder.\n+     *\n+     * @param action the action\n+     * @return this builder\n+     */\n+    default B apply(@Nonnull final Consumer<Builder<? ,?>> action) {\n+      action.accept(this);\n+      return (B) this;\n+    }\n+\n+    /**\n+     * Applies an action to this component and all child components if they are\n+     * an instance of {@link BuildableComponent}. (recursively)\n+     *\n+     * @param action the action\n+     * @return this builder\n+     */\n+    B applyDeep(@Nonnull final Consumer<Builder<?, ?>> action);\n+\n+    /**\n+     * Replaces each child of this component with the resultant component from the function.\n+     *\n+     * @param mappingFunction the mapping function\n+     * @return this builder\n+     */\n+    @Nonnull\n+    B mapChildren(@Nonnull final Function<BuildableComponent<?, ?>, BuildableComponent<?, ?>> mappingFunction);\n+\n+    /**\n+     * Replaces each child and sub-child of this component with the resultant\n+     * component of the function.\n+     *\n+     * @param mappingFunction the mapping function\n+     * @return this builder\n+     */\n+    @Nonnull\n+    B mapChildrenDeep(@Nonnull final Function<BuildableComponent<?, ?>, BuildableComponent<?, ?>> mappingFunction);","path":"src/main/java/net/kyori/text/BuildableComponent.java","position":50,"original_position":50,"commit_id":"156b0004c9aad44bca6eeb9b7ca70eff03113f03","original_commit_id":"156b0004c9aad44bca6eeb9b7ca70eff03113f03","user":{"login":"kashike","id":5474071,"avatar_url":"https://avatars0.githubusercontent.com/u/5474071?v=4","gravatar_id":"","url":"https://api.github.com/users/kashike","html_url":"https://github.com/kashike","followers_url":"https://api.github.com/users/kashike/followers","following_url":"https://api.github.com/users/kashike/following{/other_user}","gists_url":"https://api.github.com/users/kashike/gists{/gist_id}","starred_url":"https://api.github.com/users/kashike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kashike/subscriptions","organizations_url":"https://api.github.com/users/kashike/orgs","repos_url":"https://api.github.com/users/kashike/repos","events_url":"https://api.github.com/users/kashike/events{/privacy}","received_events_url":"https://api.github.com/users/kashike/received_events","type":"User","site_admin":false},"body":"name it `function`","created_at":"2017-08-16T04:39:06Z","updated_at":"2017-08-16T04:40:48Z","html_url":"https://github.com/KyoriPowered/text/pull/6#discussion_r133357780","pull_request_url":"https://api.github.com/repos/KyoriPowered/text/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/KyoriPowered/text/pulls/comments/133357780"},"html":{"href":"https://github.com/KyoriPowered/text/pull/6#discussion_r133357780"},"pull_request":{"href":"https://api.github.com/repos/KyoriPowered/text/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/KyoriPowered/text/pulls/6","id":135823169,"html_url":"https://github.com/KyoriPowered/text/pull/6","diff_url":"https://github.com/KyoriPowered/text/pull/6.diff","patch_url":"https://github.com/KyoriPowered/text/pull/6.patch","issue_url":"https://api.github.com/repos/KyoriPowered/text/issues/6","number":6,"state":"open","locked":false,"title":"Add methods to perform modifications to child components recursively","user":{"login":"lucko","id":8352868,"avatar_url":"https://avatars0.githubusercontent.com/u/8352868?v=4","gravatar_id":"","url":"https://api.github.com/users/lucko","html_url":"https://github.com/lucko","followers_url":"https://api.github.com/users/lucko/followers","following_url":"https://api.github.com/users/lucko/following{/other_user}","gists_url":"https://api.github.com/users/lucko/gists{/gist_id}","starred_url":"https://api.github.com/users/lucko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucko/subscriptions","organizations_url":"https://api.github.com/users/lucko/orgs","repos_url":"https://api.github.com/users/lucko/repos","events_url":"https://api.github.com/users/lucko/events{/privacy}","received_events_url":"https://api.github.com/users/lucko/received_events","type":"User","site_admin":false},"body":"Allows you to do stuff like this.\r\n\r\n```java\r\nBuildableComponent someComponent = LegacyComponent.from(\"&cHello &bworld.\", '&');\r\n\r\nBuildableComponent.Builder<?, ?> builder = someComponent.toBuilder();\r\n\r\nHoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of(\"Hi there!\"));\r\nbuilder.applyDeep(b -> b.hoverEvent(hoverEvent));\r\n\r\nsomeComponent = builder.build();\r\n```\r\n\r\nIn this case, take a whole component and applying a HoverEvent to everything, including all children. This is especially useful for modifying components obtained from other sources, or applying hover/click events to legacy text.\r\n\r\nAlso (perhaps) useful, is the ability to completely remap an existing component. For example, find a specific KeybindComponent, and replace it with a TextComponent.\r\n\r\n```java\r\n// some magic component\r\nBuildableComponent someComponent = null;\r\n\r\nBuildableComponent.Builder<?, ?> builder = someComponent.toBuilder();\r\n\r\n// \"Press W\"  ...  more like \"Press the forward key\"\r\n// remaps the 'key_key.forward' keybind component to a text component, if there is one present somewhere\r\nbuilder.mapChildrenDeep(c -> {\r\n    if (c instanceof KeybindComponent) {\r\n        KeybindComponent keybind = (KeybindComponent) c;\r\n        if (keybind.keybind().equals(\"key_key.forward\")) {\r\n            // uhh, no!\r\n            return TextComponent.of(\"the forward key\");\r\n        }\r\n    }\r\n    return c;\r\n});\r\n\r\nsomeComponent = builder.build();\r\n```\r\n\r\nI wasn't too sure about how it should be implemented, not sure what you'll think of it... It was [a bit easier when Components were mutable](https://github.com/lucko/text/commit/e3d62b699f2739147fcfe339c2d02fc23205d66b). :wink:\r\n\r\n","created_at":"2017-08-15T15:15:50Z","updated_at":"2017-08-16T04:40:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3e1a1c6c8b8dc914fe38bb34f19fa5caf1fa1b0c","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/KyoriPowered/text/pulls/6/commits","review_comments_url":"https://api.github.com/repos/KyoriPowered/text/pulls/6/comments","review_comment_url":"https://api.github.com/repos/KyoriPowered/text/pulls/comments{/number}","comments_url":"https://api.github.com/repos/KyoriPowered/text/issues/6/comments","statuses_url":"https://api.github.com/repos/KyoriPowered/text/statuses/156b0004c9aad44bca6eeb9b7ca70eff03113f03","head":{"label":"lucko:apply-functions","ref":"apply-functions","sha":"156b0004c9aad44bca6eeb9b7ca70eff03113f03","user":{"login":"lucko","id":8352868,"avatar_url":"https://avatars0.githubusercontent.com/u/8352868?v=4","gravatar_id":"","url":"https://api.github.com/users/lucko","html_url":"https://github.com/lucko","followers_url":"https://api.github.com/users/lucko/followers","following_url":"https://api.github.com/users/lucko/following{/other_user}","gists_url":"https://api.github.com/users/lucko/gists{/gist_id}","starred_url":"https://api.github.com/users/lucko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucko/subscriptions","organizations_url":"https://api.github.com/users/lucko/orgs","repos_url":"https://api.github.com/users/lucko/repos","events_url":"https://api.github.com/users/lucko/events{/privacy}","received_events_url":"https://api.github.com/users/lucko/received_events","type":"User","site_admin":false},"repo":{"id":93962026,"name":"text","full_name":"lucko/text","owner":{"login":"lucko","id":8352868,"avatar_url":"https://avatars0.githubusercontent.com/u/8352868?v=4","gravatar_id":"","url":"https://api.github.com/users/lucko","html_url":"https://github.com/lucko","followers_url":"https://api.github.com/users/lucko/followers","following_url":"https://api.github.com/users/lucko/following{/other_user}","gists_url":"https://api.github.com/users/lucko/gists{/gist_id}","starred_url":"https://api.github.com/users/lucko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucko/subscriptions","organizations_url":"https://api.github.com/users/lucko/orgs","repos_url":"https://api.github.com/users/lucko/repos","events_url":"https://api.github.com/users/lucko/events{/privacy}","received_events_url":"https://api.github.com/users/lucko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lucko/text","description":"A text library for Minecraft.","fork":true,"url":"https://api.github.com/repos/lucko/text","forks_url":"https://api.github.com/repos/lucko/text/forks","keys_url":"https://api.github.com/repos/lucko/text/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lucko/text/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lucko/text/teams","hooks_url":"https://api.github.com/repos/lucko/text/hooks","issue_events_url":"https://api.github.com/repos/lucko/text/issues/events{/number}","events_url":"https://api.github.com/repos/lucko/text/events","assignees_url":"https://api.github.com/repos/lucko/text/assignees{/user}","branches_url":"https://api.github.com/repos/lucko/text/branches{/branch}","tags_url":"https://api.github.com/repos/lucko/text/tags","blobs_url":"https://api.github.com/repos/lucko/text/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lucko/text/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lucko/text/git/refs{/sha}","trees_url":"https://api.github.com/repos/lucko/text/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lucko/text/statuses/{sha}","languages_url":"https://api.github.com/repos/lucko/text/languages","stargazers_url":"https://api.github.com/repos/lucko/text/stargazers","contributors_url":"https://api.github.com/repos/lucko/text/contributors","subscribers_url":"https://api.github.com/repos/lucko/text/subscribers","subscription_url":"https://api.github.com/repos/lucko/text/subscription","commits_url":"https://api.github.com/repos/lucko/text/commits{/sha}","git_commits_url":"https://api.github.com/repos/lucko/text/git/commits{/sha}","comments_url":"https://api.github.com/repos/lucko/text/comments{/number}","issue_comment_url":"https://api.github.com/repos/lucko/text/issues/comments{/number}","contents_url":"https://api.github.com/repos/lucko/text/contents/{+path}","compare_url":"https://api.github.com/repos/lucko/text/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lucko/text/merges","archive_url":"https://api.github.com/repos/lucko/text/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lucko/text/downloads","issues_url":"https://api.github.com/repos/lucko/text/issues{/number}","pulls_url":"https://api.github.com/repos/lucko/text/pulls{/number}","milestones_url":"https://api.github.com/repos/lucko/text/milestones{/number}","notifications_url":"https://api.github.com/repos/lucko/text/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lucko/text/labels{/name}","releases_url":"https://api.github.com/repos/lucko/text/releases{/id}","deployments_url":"https://api.github.com/repos/lucko/text/deployments","created_at":"2017-06-10T19:51:08Z","updated_at":"2017-06-10T19:51:10Z","pushed_at":"2017-08-15T15:22:12Z","git_url":"git://github.com/lucko/text.git","ssh_url":"git@github.com:lucko/text.git","clone_url":"https://github.com/lucko/text.git","svn_url":"https://github.com/lucko/text","homepage":"","size":196,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"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":0,"default_branch":"master"}},"base":{"label":"KyoriPowered:master","ref":"master","sha":"f7c6740857cf444b19b4d91ab255a375f9f73b2f","user":{"login":"KyoriPowered","id":25153519,"avatar_url":"https://avatars0.githubusercontent.com/u/25153519?v=4","gravatar_id":"","url":"https://api.github.com/users/KyoriPowered","html_url":"https://github.com/KyoriPowered","followers_url":"https://api.github.com/users/KyoriPowered/followers","following_url":"https://api.github.com/users/KyoriPowered/following{/other_user}","gists_url":"https://api.github.com/users/KyoriPowered/gists{/gist_id}","starred_url":"https://api.github.com/users/KyoriPowered/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KyoriPowered/subscriptions","organizations_url":"https://api.github.com/users/KyoriPowered/orgs","repos_url":"https://api.github.com/users/KyoriPowered/repos","events_url":"https://api.github.com/users/KyoriPowered/events{/privacy}","received_events_url":"https://api.github.com/users/KyoriPowered/received_events","type":"Organization","site_admin":false},"repo":{"id":80644284,"name":"text","full_name":"KyoriPowered/text","owner":{"login":"KyoriPowered","id":25153519,"avatar_url":"https://avatars0.githubusercontent.com/u/25153519?v=4","gravatar_id":"","url":"https://api.github.com/users/KyoriPowered","html_url":"https://github.com/KyoriPowered","followers_url":"https://api.github.com/users/KyoriPowered/followers","following_url":"https://api.github.com/users/KyoriPowered/following{/other_user}","gists_url":"https://api.github.com/users/KyoriPowered/gists{/gist_id}","starred_url":"https://api.github.com/users/KyoriPowered/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KyoriPowered/subscriptions","organizations_url":"https://api.github.com/users/KyoriPowered/orgs","repos_url":"https://api.github.com/users/KyoriPowered/repos","events_url":"https://api.github.com/users/KyoriPowered/events{/privacy}","received_events_url":"https://api.github.com/users/KyoriPowered/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/KyoriPowered/text","description":"A text library for Minecraft.","fork":false,"url":"https://api.github.com/repos/KyoriPowered/text","forks_url":"https://api.github.com/repos/KyoriPowered/text/forks","keys_url":"https://api.github.com/repos/KyoriPowered/text/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KyoriPowered/text/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KyoriPowered/text/teams","hooks_url":"https://api.github.com/repos/KyoriPowered/text/hooks","issue_events_url":"https://api.github.com/repos/KyoriPowered/text/issues/events{/number}","events_url":"https://api.github.com/repos/KyoriPowered/text/events","assignees_url":"https://api.github.com/repos/KyoriPowered/text/assignees{/user}","branches_url":"https://api.github.com/repos/KyoriPowered/text/branches{/branch}","tags_url":"https://api.github.com/repos/KyoriPowered/text/tags","blobs_url":"https://api.github.com/repos/KyoriPowered/text/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KyoriPowered/text/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KyoriPowered/text/git/refs{/sha}","trees_url":"https://api.github.com/repos/KyoriPowered/text/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KyoriPowered/text/statuses/{sha}","languages_url":"https://api.github.com/repos/KyoriPowered/text/languages","stargazers_url":"https://api.github.com/repos/KyoriPowered/text/stargazers","contributors_url":"https://api.github.com/repos/KyoriPowered/text/contributors","subscribers_url":"https://api.github.com/repos/KyoriPowered/text/subscribers","subscription_url":"https://api.github.com/repos/KyoriPowered/text/subscription","commits_url":"https://api.github.com/repos/KyoriPowered/text/commits{/sha}","git_commits_url":"https://api.github.com/repos/KyoriPowered/text/git/commits{/sha}","comments_url":"https://api.github.com/repos/KyoriPowered/text/comments{/number}","issue_comment_url":"https://api.github.com/repos/KyoriPowered/text/issues/comments{/number}","contents_url":"https://api.github.com/repos/KyoriPowered/text/contents/{+path}","compare_url":"https://api.github.com/repos/KyoriPowered/text/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KyoriPowered/text/merges","archive_url":"https://api.github.com/repos/KyoriPowered/text/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KyoriPowered/text/downloads","issues_url":"https://api.github.com/repos/KyoriPowered/text/issues{/number}","pulls_url":"https://api.github.com/repos/KyoriPowered/text/pulls{/number}","milestones_url":"https://api.github.com/repos/KyoriPowered/text/milestones{/number}","notifications_url":"https://api.github.com/repos/KyoriPowered/text/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KyoriPowered/text/labels{/name}","releases_url":"https://api.github.com/repos/KyoriPowered/text/releases{/id}","deployments_url":"https://api.github.com/repos/KyoriPowered/text/deployments","created_at":"2017-02-01T17:21:28Z","updated_at":"2017-08-15T08:49:51Z","pushed_at":"2017-08-16T04:37:22Z","git_url":"git://github.com/KyoriPowered/text.git","ssh_url":"git@github.com:KyoriPowered/text.git","clone_url":"https://github.com/KyoriPowered/text.git","svn_url":"https://github.com/KyoriPowered/text","homepage":"","size":161,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/KyoriPowered/text/pulls/6"},"html":{"href":"https://github.com/KyoriPowered/text/pull/6"},"issue":{"href":"https://api.github.com/repos/KyoriPowered/text/issues/6"},"comments":{"href":"https://api.github.com/repos/KyoriPowered/text/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/KyoriPowered/text/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/KyoriPowered/text/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/KyoriPowered/text/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/KyoriPowered/text/statuses/156b0004c9aad44bca6eeb9b7ca70eff03113f03"}}}}
{"actor":{"display_login":"kashike"}}