{"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka/pulls/comments/222647226","pull_request_review_id":161583096,"id":222647226,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMjY0NzIyNg==","diff_hunk":"@@ -0,0 +1,208 @@\n+/**\n+ * Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>\n+ */\n+\n+package jdocs.akka.persistence.typed;\n+\n+import akka.actor.typed.Behavior;\n+import akka.actor.typed.javadsl.ActorContext;\n+import akka.actor.typed.javadsl.Behaviors;\n+import akka.persistence.typed.PersistenceId;\n+import akka.persistence.typed.javadsl.*;\n+\n+public class AccountExample2 extends PersistentBehavior<AccountExample2.AccountCommand, AccountExample2.AccountEvent, AccountExample2.Account> {\n+\n+  interface AccountCommand {}\n+  public static class CreateAccount implements AccountCommand {}\n+  public static class Deposit implements AccountCommand {\n+    public final double amount;\n+\n+    public Deposit(double amount) {\n+      this.amount = amount;\n+    }\n+  }\n+  public static class Withdraw implements AccountCommand {\n+    public final double amount;\n+\n+    public Withdraw(double amount) {\n+      this.amount = amount;\n+    }\n+  }\n+  public static class CloseAccount implements AccountCommand {}\n+\n+  interface AccountEvent {\n+    Account applyTo(Account state);\n+  }\n+  public static class AccountCreated implements AccountEvent {\n+    @Override\n+    public Account applyTo(Account state) {\n+      return state.created(this);\n+    }\n+  }\n+  public static class Deposited implements AccountEvent {\n+    public final double amount;\n+\n+    Deposited(double amount) {\n+      this.amount = amount;\n+    }\n+\n+    @Override\n+    public Account applyTo(Account state) {\n+      return state.deposited(this);\n+    }\n+  }\n+  public static class Withdrawn implements AccountEvent {\n+    public final double amount;\n+\n+    Withdrawn(double amount) {\n+      this.amount = amount;\n+    }\n+\n+    @Override\n+    public Account applyTo(Account state) {\n+      return state.withdrawn(this);\n+    }\n+  }\n+  public static class AccountClosed implements AccountEvent {\n+    @Override\n+    public Account applyTo(Account state) {\n+      return state.closed(this);\n+    }\n+  }\n+\n+  interface Account {\n+    default Account created(AccountCreated event) {\n+      throw new IllegalStateException();","path":"akka-persistence-typed/src/test/java/jdocs/akka/persistence/typed/AccountExample2.java","position":75,"original_position":75,"commit_id":"f92c3be4bfcae342d59fd7702ab80650a9bf8807","original_commit_id":"f92c3be4bfcae342d59fd7702ab80650a9bf8807","user":{"login":"TimMoore","id":44385,"node_id":"MDQ6VXNlcjQ0Mzg1","avatar_url":"https://avatars0.githubusercontent.com/u/44385?v=4","gravatar_id":"","url":"https://api.github.com/users/TimMoore","html_url":"https://github.com/TimMoore","followers_url":"https://api.github.com/users/TimMoore/followers","following_url":"https://api.github.com/users/TimMoore/following{/other_user}","gists_url":"https://api.github.com/users/TimMoore/gists{/gist_id}","starred_url":"https://api.github.com/users/TimMoore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimMoore/subscriptions","organizations_url":"https://api.github.com/users/TimMoore/orgs","repos_url":"https://api.github.com/users/TimMoore/repos","events_url":"https://api.github.com/users/TimMoore/events{/privacy}","received_events_url":"https://api.github.com/users/TimMoore/received_events","type":"User","site_admin":false},"body":"Maybe if these methods were split into a separate interface called `AccountEventHandler` it would seem less weird?","created_at":"2018-10-04T12:28:40Z","updated_at":"2018-10-04T12:28:41Z","html_url":"https://github.com/akka/akka/pull/25726#discussion_r222647226","pull_request_url":"https://api.github.com/repos/akka/akka/pulls/25726","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/comments/222647226"},"html":{"href":"https://github.com/akka/akka/pull/25726#discussion_r222647226"},"pull_request":{"href":"https://api.github.com/repos/akka/akka/pulls/25726"}},"in_reply_to_id":222642073},"pull_request":{"url":"https://api.github.com/repos/akka/akka/pulls/25726","id":219995760,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5OTk1NzYw","html_url":"https://github.com/akka/akka/pull/25726","diff_url":"https://github.com/akka/akka/pull/25726.diff","patch_url":"https://github.com/akka/akka/pull/25726.patch","issue_url":"https://api.github.com/repos/akka/akka/issues/25726","number":25726,"state":"open","locked":false,"title":"WIP: double-dispatch event handler","user":{"login":"patriknw","id":336161,"node_id":"MDQ6VXNlcjMzNjE2MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/336161?v=4","gravatar_id":"","url":"https://api.github.com/users/patriknw","html_url":"https://github.com/patriknw","followers_url":"https://api.github.com/users/patriknw/followers","following_url":"https://api.github.com/users/patriknw/following{/other_user}","gists_url":"https://api.github.com/users/patriknw/gists{/gist_id}","starred_url":"https://api.github.com/users/patriknw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patriknw/subscriptions","organizations_url":"https://api.github.com/users/patriknw/orgs","repos_url":"https://api.github.com/users/patriknw/repos","events_url":"https://api.github.com/users/patriknw/events{/privacy}","received_events_url":"https://api.github.com/users/patriknw/received_events","type":"User","site_admin":false},"body":"* This experiment illustrates how to use double-dispatch\r\n  to implement the event handlers in the state classes.\r\n* I don't think any sane person would like to use this :-)\r\n* The builders work fine when defined outside the State, but if we\r\n  want to support a ADT style where the actual logic of how to apply\r\n  the events is defined in the concrete State classes. Due to lack\r\n  of pattern matching in Java we would have to use builders for matching\r\n  on the events, but creating a new builder for each invokation seems\r\n  very wasteful and contradicts the idea that a builder is created once\r\n  to construct the function, which is then invoked many times.\r\n* Same would be for command handlers","created_at":"2018-10-03T11:01:48Z","updated_at":"2018-10-04T12:28:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5dce2d11e03ee60e49c4b74bdd8dbb6012de9d72","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":101450254,"node_id":"MDU6TGFiZWwxMDE0NTAyNTQ=","url":"https://api.github.com/repos/akka/akka/labels/validating","name":"validating","color":"bfd4f2","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka/pulls/25726/commits","review_comments_url":"https://api.github.com/repos/akka/akka/pulls/25726/comments","review_comment_url":"https://api.github.com/repos/akka/akka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akka/akka/issues/25726/comments","statuses_url":"https://api.github.com/repos/akka/akka/statuses/f92c3be4bfcae342d59fd7702ab80650a9bf8807","head":{"label":"akka:wip-double-dispatch-patriknw","ref":"wip-double-dispatch-patriknw","sha":"f92c3be4bfcae342d59fd7702ab80650a9bf8807","user":{"login":"akka","id":1496237,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0OTYyMzc=","avatar_url":"https://avatars2.githubusercontent.com/u/1496237?v=4","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"repo":{"id":130013,"node_id":"MDEwOlJlcG9zaXRvcnkxMzAwMTM=","name":"akka","full_name":"akka/akka","private":false,"owner":{"login":"akka","id":1496237,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0OTYyMzc=","avatar_url":"https://avatars2.githubusercontent.com/u/1496237?v=4","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/akka/akka","description":"Build highly concurrent, distributed, and resilient message-driven applications on the JVM","fork":false,"url":"https://api.github.com/repos/akka/akka","forks_url":"https://api.github.com/repos/akka/akka/forks","keys_url":"https://api.github.com/repos/akka/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akka/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akka/akka/teams","hooks_url":"https://api.github.com/repos/akka/akka/hooks","issue_events_url":"https://api.github.com/repos/akka/akka/issues/events{/number}","events_url":"https://api.github.com/repos/akka/akka/events","assignees_url":"https://api.github.com/repos/akka/akka/assignees{/user}","branches_url":"https://api.github.com/repos/akka/akka/branches{/branch}","tags_url":"https://api.github.com/repos/akka/akka/tags","blobs_url":"https://api.github.com/repos/akka/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akka/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akka/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/akka/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akka/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/akka/akka/languages","stargazers_url":"https://api.github.com/repos/akka/akka/stargazers","contributors_url":"https://api.github.com/repos/akka/akka/contributors","subscribers_url":"https://api.github.com/repos/akka/akka/subscribers","subscription_url":"https://api.github.com/repos/akka/akka/subscription","commits_url":"https://api.github.com/repos/akka/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/akka/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/akka/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/akka/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/akka/akka/contents/{+path}","compare_url":"https://api.github.com/repos/akka/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akka/akka/merges","archive_url":"https://api.github.com/repos/akka/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akka/akka/downloads","issues_url":"https://api.github.com/repos/akka/akka/issues{/number}","pulls_url":"https://api.github.com/repos/akka/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/akka/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/akka/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akka/akka/labels{/name}","releases_url":"https://api.github.com/repos/akka/akka/releases{/id}","deployments_url":"https://api.github.com/repos/akka/akka/deployments","created_at":"2009-02-16T12:51:54Z","updated_at":"2018-10-04T11:15:27Z","pushed_at":"2018-10-04T12:20:33Z","git_url":"git://github.com/akka/akka.git","ssh_url":"git@github.com:akka/akka.git","clone_url":"https://github.com/akka/akka.git","svn_url":"https://github.com/akka/akka","homepage":"http://akka.io","size":214102,"stargazers_count":9071,"watchers_count":9071,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2871,"mirror_url":null,"archived":false,"open_issues_count":775,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2871,"open_issues":775,"watchers":9071,"default_branch":"master"}},"base":{"label":"akka:wip-persistenceId-patriknw","ref":"wip-persistenceId-patriknw","sha":"c1fb6d1e15da134100f09d1117cffa533f69e5cc","user":{"login":"akka","id":1496237,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0OTYyMzc=","avatar_url":"https://avatars2.githubusercontent.com/u/1496237?v=4","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"repo":{"id":130013,"node_id":"MDEwOlJlcG9zaXRvcnkxMzAwMTM=","name":"akka","full_name":"akka/akka","private":false,"owner":{"login":"akka","id":1496237,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0OTYyMzc=","avatar_url":"https://avatars2.githubusercontent.com/u/1496237?v=4","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/akka/akka","description":"Build highly concurrent, distributed, and resilient message-driven applications on the JVM","fork":false,"url":"https://api.github.com/repos/akka/akka","forks_url":"https://api.github.com/repos/akka/akka/forks","keys_url":"https://api.github.com/repos/akka/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akka/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akka/akka/teams","hooks_url":"https://api.github.com/repos/akka/akka/hooks","issue_events_url":"https://api.github.com/repos/akka/akka/issues/events{/number}","events_url":"https://api.github.com/repos/akka/akka/events","assignees_url":"https://api.github.com/repos/akka/akka/assignees{/user}","branches_url":"https://api.github.com/repos/akka/akka/branches{/branch}","tags_url":"https://api.github.com/repos/akka/akka/tags","blobs_url":"https://api.github.com/repos/akka/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akka/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akka/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/akka/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akka/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/akka/akka/languages","stargazers_url":"https://api.github.com/repos/akka/akka/stargazers","contributors_url":"https://api.github.com/repos/akka/akka/contributors","subscribers_url":"https://api.github.com/repos/akka/akka/subscribers","subscription_url":"https://api.github.com/repos/akka/akka/subscription","commits_url":"https://api.github.com/repos/akka/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/akka/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/akka/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/akka/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/akka/akka/contents/{+path}","compare_url":"https://api.github.com/repos/akka/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akka/akka/merges","archive_url":"https://api.github.com/repos/akka/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akka/akka/downloads","issues_url":"https://api.github.com/repos/akka/akka/issues{/number}","pulls_url":"https://api.github.com/repos/akka/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/akka/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/akka/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akka/akka/labels{/name}","releases_url":"https://api.github.com/repos/akka/akka/releases{/id}","deployments_url":"https://api.github.com/repos/akka/akka/deployments","created_at":"2009-02-16T12:51:54Z","updated_at":"2018-10-04T11:15:27Z","pushed_at":"2018-10-04T12:20:33Z","git_url":"git://github.com/akka/akka.git","ssh_url":"git@github.com:akka/akka.git","clone_url":"https://github.com/akka/akka.git","svn_url":"https://github.com/akka/akka","homepage":"http://akka.io","size":214102,"stargazers_count":9071,"watchers_count":9071,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2871,"mirror_url":null,"archived":false,"open_issues_count":775,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2871,"open_issues":775,"watchers":9071,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/25726"},"html":{"href":"https://github.com/akka/akka/pull/25726"},"issue":{"href":"https://api.github.com/repos/akka/akka/issues/25726"},"comments":{"href":"https://api.github.com/repos/akka/akka/issues/25726/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka/pulls/25726/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akka/akka/pulls/25726/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka/statuses/f92c3be4bfcae342d59fd7702ab80650a9bf8807"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"TimMoore"}}